Upload
nikhilnisha
View
87
Download
1
Tags:
Embed Size (px)
Citation preview
Con
quer
ing
Com
plex
and
Cha
ngin
g Sy
stem
sO
bjec
t-O
rien
ted
Soft
war
e E
ngin
eeri
ng Chapter 5, Analysis:Object Modeling
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 2
Software Lifecycle Activities
Application
Domain Objects
SubSystems
class...class...class...
Implementation
Domain Objects
SourceCode
Test Cases
?
Expressed in Terms Of
Structured By
Implemented
ByRealized By Verified By
SystemDesign
ObjectDesign
Implemen-tation Testing
class....?
RequirementsElicitation
Use CaseModel
RequirementsAnalysis
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 3
Outline
1. Overview of Analysis Model Inputs - requirements model (use cases) Outputs or parts of the Analysis Model
dynamic model Develop preliminary sequence diagrams to illustrate the interaction
between objects Develop state diagrams for objects with interesting behavior
static model Develop preliminary object and class diagrams showing the structure
of the system Heuristics to help create the Analysis Model
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 4
Requirements Model, Analysis Model, Design Models 1. Analyze the problem statement
Identify functional requirements Identify nonfunctional requirements Identify constraints (pseudo requirements)
2. Build the functional model Develop use cases to illustrate functionality requirements
3. Build the dynamic model Develop sequence diagrams to illustrate the interaction between objects Develop state diagrams for objects with interesting behavior
4. Build the static model Develop object and class diagrams showing the structure of the system
5. Use the analysis model (static and dynamic) to create the architecture and the (detailed) design models
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 5
Analysis: UML Activity Diagram
Reviewmodel
Consolidatemodel
Defineentity
Defineboundary
Definecontrol
Defineinteractions
Defineassociations
Defineattributes
Definenontrivialbehavior
Defineparticipating
Defineuse cases
objects
objects objectsobjects
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 6
Analysis Model: - model structure and behavior of objects-start with objects seen by from client’s perspective Structure - Static model Behavior - Dynamic model Static and dynamic modeling need to be done at the same time
Creating the Analysis Model Input model: requirements model (use cases) Output models: static and dynamic models
Subsequently, the analysis model is the input for creating the architecture and (detailed) design models
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 7
Analysis Model
Steps during dynamic modeling use case event flows (normal, alternate) heuristic: start with 1 sequence diagram per use case
if alternate flows are complex, then consider using separate sequence diagrams for each alternate flow
Steps during static modeling 1. Object/Class identification
heuristic: start with the nouns in the use cases event flows 2. Find the attributes
heuristic: nouns 3. Find the methods
Basic methods include Create, Read, Update, Delete (CRUD) 4. Find the associations between classes
Association, generalization, aggregation, composition 5. Find the multiplicity relationship between classes
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 8
Static Modeling with UML Classes Associations (Relations)
Part of- Hierarchy (Aggregation) Kind of-Hierarchy (Generalization)
Attributes Detection of attributes Application specific Attributes in one system can be classes in another system
Operations/Signature/Methods Generic methods Domain specific methods
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 9
Dynamic Modeling with UML Diagrams for dynamic modeling Interaction diagrams
Sequence Diagram: Dynamic behavior of a set of objects arranged in time sequence. Good for real-time specifications and complex scenarios
Collaboration Diagram : Shows the relationship among objects. Does not show time
Statecharts: A state machine that describes the response of an object of a given
class to the receipt of outside stimuli (Events). Activity Diagram:
Special type of statechart where all states are action states
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 10
Heuristics or Guidelines - Where do we start?
Class Identification Identify the boundary (or interface) objects of the system Identify the important entity objects in the system Identify control objects in the system Class identification is crucial to object-oriented modeling Basic assumption:
1. We can find the classes for a new software system (Forward Engineering)
2. We can identify the classes in an existing system (Reverse Engineering)
Why can we do this? Philosophy, science, experimental evidence
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 11
Object vs. Class Object (instance): Exactly one thing
The lecture on September 7 on Software Engineering from 9:00 -10:20
A class describes a group of objects with similar properties IETM, Author, Corrosion, Work order
Class diagram: A graphic notation for modeling classes and their relationships ("associations")
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 12
How do you find classes?
Learn about problem domain: Observe your client Apply general world knowledge and intuition Apply design patterns Try to establish a taxonomy Take the flow of events and find participating objects in use
cases Do a textual analysis of scenario or flow of events (Abbott
Textual Analysis, 1983)Nouns are good candidates for classes
Heuristic (for 6354): start with the points in blue
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 13
Mapping parts of speech to object model components [Abbot 1983]
Part of speech Model component Example
Proper noun object Jim Smith
Improper noun class Toy, doll
Doing verb method Buy, recommend
being verb inheritance is-a (kind-of)
having verb aggregation has an
modal verb constraint must be
adjective attribute 3 years old
transitive verb method enter
intransitive verb method (event) depends on
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 14
Example: Use Case – from Dental Office System- input for creating the Analysis Model
Title: Search for Supplier InformationPreconditions: Dental Office System has been initializedPostconditions: If the search is successful, then the supplier information is
displayed. If the search is not successful, then an error message is displayed.
Normal Flow: The Operator requests to search for supplier. The Operator may perform a
keyword search using the boolean operators “not”, “and”, and “or”. The Operator may enter up to three keywords
The system displays the name, phone number, fax number, and address of the suppliers that match the search criteria.
Alternate Flow The Operator requests to search for supplier. The Operator may perform a
keyword search using the boolean operators “not”, “and”, and “or”. If no matches are found, then the system displays an error message to the
Operator.
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 15
Example: Use Case – from Dental Office System// Circle the nouns (focus on the normal and alternate flows)Title: Search for Supplier InformationPreconditions: Dental Office System has been initializedPostconditions: If the search is successful, then the supplier information is displayed. If the search is not
successful, then an error message is displayed.
Normal Flow:1. The Operator requests to search for supplier. The Operator may perform
a keyword search using the boolean operators “not”, “and”, and “or”. The Operator may enter up to three keywords
2. The system displays the name, phone number, fax number, and address of the suppliers that match the search criteria to the Operator.
Alternate Flow1. The Operator requests to search for supplier. The Operator may perform
a keyword search using the boolean operators “not”, “and”, and “or”. 2. If no matches are found, then the system displays an error message to the
Operator.// I started here with proper nouns (actors). // Exercise: identify nouns/possible objects and attributes
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 16
UML: Class and Object Diagrams
Supplier
ACME Floss:Supplier
Vogue:Supplier
:Supplier
Class Diagram
Object Diagram
AnonymousObject
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 17
phone: string
Attributes and Values
name:stringaddress: string
Supplier ACME Floss:Supplier
fax: string phone: 972-883-4216
name:ACME Floss Inc.address: 1607 N. Floyd RdRichardson, Texas, USA
fax: 972-883-2349
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 18
Operation, Signature or Method?
Operation: A function or transformation applied to objects in a class. All objects in a class share the same operations (Analysis Phase)
Signature: Number & types of arguments, type of result value. All methods of a class have the same signature (Object Design Phase)
Method: Implementation of an operation for a class (Implementation Phase)
Workorder
File_name: StringSize_in_bytes: integerLast_update: dateStickies: array[max]
print()delete()open()close()write()read()
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 19
Links and Associations
Links and associations establish relationships among objects and classes.
Link: A connection between two object instances. A link is an instance of an association
Association: Bidirectional mapping. One-to-one, many-to-one, one-to-many, An association describes a set of links like a class describes a set of
objects. Generalization, aggregation, composition, and others
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 20
Object Types Entity Objects
Represent the persistent information tracked by the system (Application domain objects, “Business objects”)
Boundary Objects Represent the interaction between the user and the system
Control Objects: Represent the control tasks performed by the system
Having three types of objects leads to models that are more resilient to change. The boundary of a system changes more likely than the control The control of the system change more likely than the application
domain
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 21
Example: Use Case – from Dental Office System// Circle the nouns (focus on the normal and alternate flows)Title: Search for Supplier InformationPreconditions: Dental Office System has been initializedPostconditions: If the search is successful, then the supplier information is displayed. If the search is not
successful, then an error message is displayed.
Normal Flow: The Operator requests to search for supplier. The Operator may perform
a keyword search using the boolean operators “not”, “and”, and “or”. The Operator may enter up to three keywords.
The system displays the name, phone number, fax number, and address of the suppliers that match the search criteria to the Operator.
Alternate Flow The Operator requests to search for supplier. The Operator may perform
a keyword search using the boolean operators “not”, “and”, and “or”. If no matches are found, then the system displays an error message to the
Operator.// Supplier is an entity object; what are name, phone, fax, and address?// Boundary objects? Control objects?
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 22
TIP
If you organize your boundary objects on the left, then this model is going to be organized in a similar way to your sequence diagrams
Example: Dental Office System- describe as classes- if needed, generalize the objects
<<entity>>Supplier
<<control>>DentalOfficeControl
<<boundary>>GUI
<<entity>>Client
<<control>>...
<<entity>>Dental Office
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 23
Static Modeling in Practice: Encourage Brainstorming
Find New Objects (nouns in use case)
Iterate on Names, Attributes and Methods
Find Associations between Classes, Links between Objects
Label the associations, links
Determine the multiplicity of the associations
Iteratively refine the model•Don’t put too many objects/classes into the same package: 7+-2
Generalize as a Class
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 24
Example: Dental Office System- a place to start
<<entity>>Supplier
<<boundary>>DentalOfficeGUIBoundary
<<entity>>Client
<<control>>DentalOfficeControl
<<entity>>Appointment
nameaddressphonefax
addmodifysearchdelete
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 25
Dynamic Modeling
Definition of dynamic model: A collection of sequence diagrams; one state chart diagram for
each class with important dynamic behavior. Purpose:
Identify signatures for the object model Verify the use cases
How do we do this? Start with use case (or scenario) Model interaction between objects to create sequence diagram Model dynamic behavior of single objects to create Statechart
diagram
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 26
Sequence Diagram
From the flow of events in the use case proceed to the sequence diagram
A sequence diagram is a graphical description of objects participating in a use case
Relation to object identification: Objects/classes have already been identified during object
modeling New objects are identified as a result of dynamic modeling
Find/correct errors of omission Heuristic:
Events in a use case are externally visible The events map to interactions between an actor and a boundary
object in the sequence diagram For each interaction in the use case there is an interaction in the
sequence diagram between actors and boundary objects
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 27
Heuristics for Sequence Diagrams
Layout: 1st column: Should correspond to the actor who initiated the use case 2nd column: often a boundary object 3rd column: often a control object that manages the rest of the use
case Creation:
When is each object created? Highly related to use case that initializes the system
Access: Entity objects are accessed by control and boundary objects, Entity objects should never call boundary or control objects: This
makes it easier to share entity objects across use cases and makes entity objects resilient against technology-induced changes in boundary objects.
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 28
Sequence Diagram- a place to start
:DentalOfficeControl
ACME Floss:Supplier
Request Search for Suppliers
:Operator
Supplier name, phone, fax, address
Penultimate Floss:Supplier
Search for Supplier
Search for Supplier Response
:DentalOfficeGUIBoundary
create()
...Collection of suppliers’ name, phone, fax, address
Enter searchcriteria
search()