SWE 316: Software Design and Architecture Objectives Lecture 3 Object Orientation SWE 316: Software Design and Architecture NOTE: most slides are adapted.

Slides:



Advertisements
Similar presentations
Introduction to Object Orientation System Analysis and Design
Advertisements

©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Unified Modeling Language
Inheritance Inheritance Reserved word protected Reserved word super
Ch 12: Object-Oriented Analysis
Object-Oriented Analysis and Design
Introduction To System Analysis and Design
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
UML – Class Diagrams.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Object Oriented System Development with VB .NET
Irwin/McGraw-Hill Copyright © 2004 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS6th Edition.
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
Basic OOP Concepts and Terms
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Software Lifecycle A series of steps through which a software product progresses Lifetimes vary from days to months to years Consists of –people –overall.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 10 Classes Continued
C++ fundamentals.
ACM/JETT Workshop - August 4-5, 2005 UML Modeling using MagicDraw UML for Java Programmers.
(c) University of Washington03-1 CSC 143 Java Inheritance Reading: Ch. 10.
Introduction To System Analysis and design
Introduction to Object Oriented Design. Topics Designing Your Own Classes Attributes and Behaviors Class Diagrams.
Programming Languages and Paradigms Object-Oriented Programming.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed.
Chapter 2 Object Orientation. Process Phase Affected by This Chapter Requirements Analysis Design Implementation ArchitectureFrameworkDetailed Design.
Prologue: The Software Process. Main Phases of Software Process 1. Requirements Analysis (answers “WHAT?”) Specifying what the application must do 2.
Chapter 5 Design Principles II: Flexibility, Reusability, and Efficiency.
Lecture # 06 Design Principles II
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
Chapter 5 Design Principles II: Flexibility, Reusability, and Efficiency.
1.  A method describes the internal mechanisms that actually perform its tasks  A class is used to house (among other things) a method ◦ A class that.
Unified Modeling Language, Version 2.0
1. 2 Object-Oriented Concept Class & Object Object-Oriented Characteristics How does it work? Relationships Between Classes Development Tools Advantage.
Introduction To System Analysis and Design
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences University of Scranton October 18, 2015October 18, 2015October 18, 2015.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Chapter 16 Applying UML and Patterns Craig Larman
SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
Introduction To OOP 1.0 Fundamentals Of Java Programming Language 2.0 Exception Handling 3.0 Classes, Inheritance And Polymorphism © 2011 | PN AZRINA.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 13 Creational Design Pattern SWE 316: Software Design and Architecture.
Chapter 4 Introduction to Classes, Objects, Methods and strings
9 - Class & Method Design Model Enhancement Design to Code Proposal Presentation.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Chapter 7 Creational Design Pattern. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFrameworkDetailed.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 6 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
DATA REQIREMENT ANALYSIS
Object-Oriented Analysis and Design
About the Presentations
Object Orientation Yaodong Bi, Ph.D. Department of Computer Sciences
Creating and Using Classes
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
Week 6 Object-Oriented Programming (2): Polymorphism
Systems Analysis – ITEC 3155 Modeling System Requirements – Part 2
Basic OOP Concepts and Terms
Presentation transcript:

SWE 316: Software Design and Architecture Objectives Lecture 3 Object Orientation SWE 316: Software Design and Architecture NOTE: most slides are adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission. Ch 2

SWE 316: Software Design and Architecture Before Object Orientation Real world concepts Software Design Entities Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Object Orientation Classes and ObjectsExamplePolymorphismInterfacesThings to be considered 2/24

SWE 316: Software Design and Architecture Goals of Object Orientation How Do We Express Ourselves? "Customers Montague and Susan entered the Ajax bank and were served by teller Andy..... " AJAX BANK Sec 2.1 page 44 Object Orientation Classes and ObjectsExamplePolymorphismInterfacesThings to be considered 3/24

SWE 316: Software Design and Architecture How We Express Ourselves " Customer s Montague and Susan entered the Ajax bank and were served by teller Andy..... " CLASSES OBJECTS Note that Java code convention reverses this capitalization. Object Orientation Classes and ObjectsExamplePolymorphismInterfacesThings to be considered 4/24

SWE 316: Software Design and Architecture Object Orientation Real world concepts Software design entities Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Skljkvjkvjfkavjafkk saovjsdvjfvkfjvkfjk Account getDetails() Transaction execute() Customer getFirstName() Direct correspondence Graphics reproduced with permission from Corel. Object Orientation Classes and ObjectsExamplePolymorphismInterfacesThings to be considered 5/24

SWE 316: Software Design and Architecture Benefits of OO Object orientation provides a direct mapping between concepts and code Object Orientation Classes and ObjectsExamplePolymorphismInterfacesThings to be considered 6/24

SWE 316: Software Design and Architecture Classes and Objects AjaxCustomer Real worldClass in Design (UML notation) Class in Source code (Java) class AjaxCustomer {.... } PermissionToPay class PermissionToPay {.... } Mental concept Sec 2.2 page 46 Object Orientation Classes and Objects ExamplePolymorphismInterfacesThings to be considered 7/24

SWE 316: Software Design and Architecture The Members of a Class Auto public int vehicleID … protected int mileage … private myPrivateVariable … static int numAutosMade … Class model Toyota numAutosMade aliceBrownBMW:Auto … mileage jaynesCar:Auto … mileage Objects of Auto Subclasses have these members too myToyota:Toyota … mileage 2105 … Static variable: One version only Non-static variable: One version for every object Object Orientation Classes and Objects ExamplePolymorphismInterfacesThings to be considered 8/24

SWE 316: Software Design and Architecture Attribute Types (Shlaer & Mellor)  Naming:  fixed for each object  distinguishes individuals  Descriptive:  varies through life of object  Referential:  ties instance of one class to instance(s) of another  == aggregation Auto vehicleID mileage owner Object Orientation Classes and Objects ExamplePolymorphismInterfacesThings to be considered 9/24

SWE 316: Software Design and Architecture Classes and Objects  A class expresses a concept such as “HondaCivic.”  An object is an instance of a class such as “the Honda Civic with vehicle ID 89R783HJD894.” Object Orientation Classes and Objects ExamplePolymorphismInterfacesThings to be considered 10/24

SWE 316: Software Design and Architecture The Clients of a Class class Customer {... String getName() { … } int computeBalance() { … }... } class AjaxWebsiteGenerator {... void makeProfile( Customer c ) { … String name = c.getName() … }... } class AjaxAssets {... int computeAssets() {... Customer c = customers[ i ]; assets += c.computeBalance();... }... } Client of Customer Object Orientation Classes and Objects ExamplePolymorphismInterfacesThings to be considered 11/24

SWE 316: Software Design and Architecture Why OO is Useful for Application Development?  Class (Sec 2.2.1)  basic motive of Object Orientation  identifying parts that corresponds to the real world  Instantiation (Sec 2.2.2)  creating instances of encapsulated concepts  Inheritance (Sec 2.3.1)  capturing the way concepts occur in hierarchy  Polymorphism (Sec 2.3.2)  capturing use of single action word to represent different things, depending on context Object Orientation Classes and Objects ExamplePolymorphismInterfacesThings to be considered 12/24

SWE 316: Software Design and Architecture Requirements For Creation Example 1. Summary: Produces text for various types of customers. 2. Detailed requirements 2.1 The application displays choices to the console, as shown in figure For customers delinquent more than 90 days, the e- mail message generated is the statement shown in figure Page 1 of 4 Object OrientationClasses and Objects Example PolymorphismInterfacesThings to be considered 13/24

SWE 316: Software Design and Architecture Requirements For Creation Example 2.3 All non-delinquent customers receive a tailored messages as follows Mountain customers: This month we have a special on West Face tents. Only $ lots more output specialized to mountaineering customers Regular customers: All items are marked down 20% for this month only.... lots more output for regular customers... Page 3 of 4 Object OrientationClasses and Objects Example PolymorphismInterfacesThings to be considered 14/24

SWE 316: Software Design and Architecture Requirements For Creation Example 2.4 The is to be displayed on the console. 3. Future enhancements We anticipate that the text is likely to change frequently, and that new kinds of customers are likely to be specified, each with its own new set of requirements. Page 4 of 4 Object OrientationClasses and Objects Example PolymorphismInterfacesThings to be considered 15/24

SWE 316: Software Design and Architecture Disadvantages of Branching  Code for each case not cohesive (“cohesive”: forms a comprehensible unity)  All types of customers coded together in single class Expensive to …  … add new functionality  bloat switch or if - then code  … remove functionality  hunt for all parts that must be removed  … change functionality  hunt for all parts that must be changed Object OrientationClasses and Objects Example PolymorphismInterfacesThings to be considered 16/24

SWE 316: Software Design and Architecture Aspects of the Customer Design Needing Improvement  We need to visualize the design  Code not an effective way to understand design  The design’s maintainability still has flaws  As the application grows, specialized class(es) will be required to interact with the user Object OrientationClasses and Objects Example PolymorphismInterfacesThings to be considered 17/24

SWE 316: Software Design and Architecture What’s Needed to Specify Functionality  Name of the function Example: add  Argument types(if any) Example:  First parameter: integer  Second parameter: float  Return type Example: double, reference type, void  Exceptions (if any) Example: IOException  More(?)  Are parameters inputs and/or outputs?  Describe what the function does (natural language) Object OrientationClasses and Objects Example PolymorphismInterfacesThings to be considered 18/24

SWE 316: Software Design and Architecture Polymorphism  the use of several versions of a method, one in each derived class.  This enables objectOfBaseClass.theMethod() to be interpreted variously at runtime, depending on what derived class objectOfBaseClass belongs to. Object OrientationClasses and ObjectsExample Polymorphism InterfacesThings to be considered 19/24

SWE 316: Software Design and Architecture The Need For Interfaces: Simplify … class Draw { … int setColor( String ) { … } Pen getStandardPen() { … } int getLogoStyle() { … } void setColor( int ) { … } void drawLogo( int, int ) { … } void speedUpPen( int ) { … } … } Object OrientationClasses and ObjectsExamplePolymorphism Interfaces Things to be considered 20/24

SWE 316: Software Design and Architecture Interface Example: a Draw Class  Functions dealing with the pen used  Pen getStandardPen()  void speedUpPen( int ) ...  Functions dealing with the colors available  void setColor( int )  int setColor( String ) ...  Functions covering the drawing of the company’s logo  void drawLogo( int, int )  int getLogoStyle() ... } } } Pen interface Color interface Logo interface Object OrientationClasses and ObjectsExamplePolymorphism Interfaces Things to be considered 21/24

SWE 316: Software Design and Architecture Interfaces An interface is a set of function prototypes (each with name, parameter types, return type, exception type). Object OrientationClasses and ObjectsExamplePolymorphism Interfaces Things to be considered 22/24

SWE 316: Software Design and Architecture Issues to be Addressed  How do we visualize a set of classes?  How can classes relate to each other?  How should classes relate to each other?  How can we describe functionality occurring among several classes?  How do we describe the manner in which objects respond to events occurring on them?  Are there patterns of class usage that recur?  So we can existing reuse design parts Object OrientationClasses and ObjectsExamplePolymorphismInterfaces Things to be considered 23/24

SWE 316: Software Design and Architecture Summary of This Chapter  A Class represents a concept  Example: House  An Object is an instance of a class  Example: 23 Main Street, Springfield  Classes can relate in several ways: Mainly …  A Client of a class refers to that class in one of its methods  Inheritance: “kind of” relationship  Aggregation: “has a” relationship, explained in chapter xx  Polymorphism means “action depends on context”  Executing anObject.aMethod() actually executes the version of aMethod() in the subclass that anObject belongs to Object OrientationClasses and ObjectsExamplePolymorphismInterfacesThings to be considered 24/24