object-oriented modeling: static models. object-oriented modeling model the system as interacting...
TRANSCRIPT
Object-Oriented Modeling
Model the system as interacting objectsModel the system as interacting objects Match experienceMatch experience
We are surrounded by objects: people, trees, We are surrounded by objects: people, trees, cars, towns and houses cars, towns and houses
Objects are related to each otherObjects are related to each other Reduce the "semantic gap" Reduce the "semantic gap"
Key Object-oriented ideas (Pfleeger)
IdentityIdentity AbstractionAbstraction ClassificationClassification EncapsulationEncapsulation InheritanceInheritance PolymorphismPolymorphism PersistencePersistence
OO Concepts (Eriksson et al, 2004)
OO is a technology for producing models that reflect a OO is a technology for producing models that reflect a domaindomain
Every object is an instance of a class. Objects have names, Every object is an instance of a class. Objects have names, attributes, and operations. attributes, and operations.
OO models, when constructed correctly, are easy to OO models, when constructed correctly, are easy to communicate, change, expand, validate, and verify.communicate, change, expand, validate, and verify.
OO systems are flexible, have well-defined architectures, OO systems are flexible, have well-defined architectures, and provide reusable components.and provide reusable components.
OO models are conveniently implemented in software, but OO models are conveniently implemented in software, but OO is more than just programming constructs.OO is more than just programming constructs.
OO requires a method that integrates development and OO requires a method that integrates development and modeling.modeling.
Advantages of O-O Approach Requires analysisRequires analysis Emphasis on data and function. Emphasis on data and function. Seamless development process. Seamless development process.
Use analysis models for design and Use analysis models for design and implementationimplementation
Progressively refine work rather than converting Progressively refine work rather than converting from one representation to anotherfrom one representation to another
Iterative rather than sequential. Iterative rather than sequential. Each iteration builds on previous workEach iteration builds on previous work Progress from analysis to design to implementationProgress from analysis to design to implementation Avoid replacing previous workAvoid replacing previous work
OO Analysis Objective
To develop precise, concise, To develop precise, concise, understandable, and correct models of the understandable, and correct models of the problem context.problem context.
Object Modeling
Involves systems analysis and design based Involves systems analysis and design based on three different views of the system: on three different views of the system: Object ModelsObject Models Dynamic ModelsDynamic Models Functional ModelsFunctional Models
Activities and Products of OOA
0. State the requirements0. State the requirements
1. Build an Object Model1. Build an Object Model
2. Develop a Dynamic Model2. Develop a Dynamic Model
3. Construct a Functional Model3. Construct a Functional Model
4. Verify, iterate, and refine the three models4. Verify, iterate, and refine the three models
1. Build an Object Model
Identify objects and classes Identify associations between objects Identify attributes of objects and
associations Organize and simplify object classes using
inheritance Verify that paths exist for likely operations
2. Develop a Dynamic Model
Prepare scenarios of typical interaction Prepare scenarios of typical interaction sequencessequences
Identify Events between objects and prepare Identify Events between objects and prepare an event tracean event trace
Build a state diagram, sequence diagram, or Build a state diagram, sequence diagram, or communication diagramcommunication diagram
Match events between objects to verify Match events between objects to verify consistencyconsistency
3. Construct a Functional ModelIdentify Input and Output ValuesIdentify Input and Output Values
Build Use Case scenariosBuild Use Case scenarios
Build Data Flow Diagrams showing Build Data Flow Diagrams showing functional dependencies functional dependencies
Describe FunctionsDescribe Functions
Identify ConstraintsIdentify Constraints
Specify Optimization CriteriaSpecify Optimization Criteria
Objects often correspond to nouns May represent physical entitiesMay represent physical entities
May represent concepts or rolesMay represent concepts or roles
May represent an interactionMay represent an interaction
Classes
A A classclass is a "template" describing a set of is a "template" describing a set of objects with objects with similar properties (attributes), similar properties (attributes), common behavior (operations), common behavior (operations), common relationships to other objects, common relationships to other objects,
and and common semantics. common semantics.
Instances
An instance of a class is an object An instance of a class is an object created at runtimecreated at runtime based on a class (template). based on a class (template). Sometimes class and object are used to Sometimes class and object are used to
mean the same thing (by mistake).mean the same thing (by mistake). An instance is used to refer to exactly one An instance is used to refer to exactly one
thing.thing.
Attribute
(The abstraction of) a single characteristic (The abstraction of) a single characteristic possessed by all the instances of a class. possessed by all the instances of a class.
How to recognize attributes Descriptive attributes. Descriptive attributes.
Provide facts intrinsic to each instance of an object.Provide facts intrinsic to each instance of an object.
Naming Attributes. Naming Attributes. Provide facts about the arbitrary labels and names Provide facts about the arbitrary labels and names
carried by each instance of an object.carried by each instance of an object.
Referential Attributes. Referential Attributes. Capture the facts that tie an instance of one object to an Capture the facts that tie an instance of one object to an
instance of another object.instance of another object.
Operations and Methods
Behavior of objects is realized via Behavior of objects is realized via operationsoperations.. a function or transformation that may be a function or transformation that may be
applied applied to objects in a class. to objects in a class. by objects in a classby objects in a class
All objects in a class share the same operations.All objects in a class share the same operations. Method: Method: the implementation of an operation. the implementation of an operation. Operations usually correspond to verbs in a Operations usually correspond to verbs in a
natural language. (natural language. (print, open, transform, mailprint, open, transform, mail))
Recognizing Operations Manipulate data: Manipulate data:
Perform a calculation. Perform a calculation.
Monitor the object to verify the occurrence of an Monitor the object to verify the occurrence of an event that is controlling the object. event that is controlling the object.
UML Class Diagram
Class Name
Class Name
Attributes
Operations
These may be abstract or at the source code
level
UML Class Diagrams
Employee
Employee
Name:
ID:
SetName (string): void
(Employee)Joe
The box on the right is an instance of the Employee object.
Class Relationships
Aggregation
Dependency Relationship between two elements, one independent, one dependent
Association A connection between two classes
Generalization A relationship between a more general and a more specific class. The more specific can contain additional information
An association that suggests that one class contains another
Shared Aggregation
Class A Class BRole A
Role B
The diamond is open (not filled).
This says “B is a part of A.”
A is made of B’s. The B’s are part of A.
Composition Aggregation
Class A Class BRole A
Role B
Here the diamond is filled.
The part object may belong to only one whole.
The parts are expected to live and die with the whole. If the whole is deleted, the parts go with it.
UML notation: subtypes/generalization
Customer
Corporate Customer
Private Customer
Every attribute of Customer is also an attribute of its subclasses.
Notes: Subtypes/Supertypes: Inheritance Every subtype must have the “is a” Every subtype must have the “is a”
relationship with its supertype.relationship with its supertype. These are also known as “parent class” and These are also known as “parent class” and
“child class”.“child class”. All attributes and methods of the parent are All attributes and methods of the parent are
also attributes and methods of the child.also attributes and methods of the child.