Software EngineeringSoftware Engineering
Object Oriented Analysis
ObjectivesObjectives
To explain Class-Responsibility-Collaborator Modelling.
To provide an example of CRC modelling in action
Analysis = Process + ModelsAnalysis = Process + Models
Process Model Output
1. Elicit customer requirements and identify use-cases
Use-Case Diagrams
2. Extract candidate classes, Identify attributes and methods, Define a class hierarchy
Class Responsibility Collaborator (CRC) Cards
3. Build an object-relationship model
Class Diagram
4. Build an object-behaviour model
Interaction Diagram
Class-Responsibility-Collaborator Class-Responsibility-Collaborator ModellingModelling
A simple means of identifying and organizing classes Not an official part of UML A CRC model is a collection of index cards that represent
classes Each CRC card contains:
Class name, type, characteristic Responsibilities Collaborations
Index cards because they can only hold a limited amount of information enforces high-level analysis
Steps in CRC modelling: Identify [1] Classes, [2] Responsibilities, [3] Collaborators, [4] Review the Model
CRC BenefitsCRC Benefits
They are portable. No computers are required so they can be used anywhere. Even away from the office.
They allow the participants to experience first hand how the system will work.
CRC CardsCRC Cards
class name:
class type: (e.g., device, property, role, event, ...)
class characteristics: (e.g., tangible, atomic, concurrent, ...)
responsibilities: collaborators:
[1] Identifying Classes[1] Identifying Classes
Classes and Objects are extracted from the Use-Cases by doing a grammatical parse
Grammatical Parse: Underline nouns or noun clauses (these describe candidate objects)
Enter the candidate objects (and their associated classes) into a table
Remove synonyms
Solution Space: objects required to implement the solution
Problem Space: objects required to describe the problem
“The really hard problem [in OO] is discovering what are the ‘right’ objects in the first place”
Accepting ClassesAccepting Classes
1. Objects are accepted if they satisfy all (or almost all) of the following requirements:
2. Retained Information: the system needs to remember data about the object
3. Needed Services: the object must have an identifiable set of operations
4. Multiple Attributes: during analysis we focus on major information only. Objects should have many attributes
5. Common Attributes: A set of attributes apply to all occurrences of the object
6. Common Operations: A set of operations apply to all occurrences of the object
7. Essential Requirements: external entities that produce or consume essential information
Class TypesClass Types
1. Accepted classes are assigned a type:
2. External entities - other systems, devices, people
3. Things - reports, displays, signals
4. Occurrences or events - property transfer, completion of a series of robot movements
5. Roles - manager, engineer, sales person
6. Organizational Units - division, group, team
7. Places - manufacturing floor, loading dock
8. Devices - four-wheeled vehicles, computers
9. Property - of the problem, e.g. credit rating
10. Interaction - model interaction that occur among other objects, e.g. a purchase or a license
Class CharacteristicsClass Characteristics
1. Accepted classes are assigned a set of characteristics:
2. Tangibility: does the class represent a tangible (physical) or abstract (information) entity?
3. Inclusiveness: is the class atomic (includes no other classes) or aggregate (has at least one nested object)?
4. Sequentiality: is the class concurrent (has its own thread of control) or sequential (scheduled by outside resources)?
5. Persistence: is the class transient (created and removed during program operation), temporary (created during program operation and removed at termination) or permanent (stored in a database)?
6. Integrity: is the class corruptible (does not protect its resources from outside influence) or guarded (the class enforces access control)?
Example: Identifying ClassesExample: Identifying Classes
Narrative: SafeHome software enables the homeowner to configure the
security system when it is installed, monitors all sensors connected to the security system, and interacts with the homeowner through a keypad and function keys contained in the SafeHome control panel.
During installation, the SafeHome control panel is used to “program” and configure the system. Each sensor is assigned a number and type, a master password is programmed for arming and disarming the system, and telephone number(s) are input for dialing when a sensor event occurs.
…
Potential Objects/Classes Homeowner, sensor, control panel, installation, system (alias
security system), number, type, master password, telephone number, sensor event, …
Example: Accepting ClassesExample: Accepting Classes
Potential Object/Class Class requirements
Homeowner Rejected: 1, 2 (retained information, needed service) fail
Sensor Accepted: all apply
Control Panel Accepted: all apply
Installation rejected
System Accepted: all apply
Number and Type Rejected: 3 (multiple attributes) fails, attribute of sensor
Master Password Rejected: 3 fails
Telephone Number Rejected: 3 fails
Sensor Event Accepted: all apply
Example: CRC HeaderExample: CRC Header
class name: Sensor
class type: external entity
class characteristics: tangible, atomic, concurrent, guarded
responsibilities: collaborators:
[2] Identifying Responsibilities[2] Identifying Responsibilities
Responsibilities (attributes and methods) are extracted from the Use-Cases descriptions
Attributes: Describe the object Select those things that reasonably belong to an object Question: What data items fully define this object in the context of
the particular use-case?
Methods (Operations): Define the behaviour of the object and alter the object’s attributes Types of operations – data manipulation, computation, event
monitoring Do a grammatical parse of the Use-Case description and isolate
verbs
Guidelines for Allocating Guidelines for Allocating Responsibilities to ClassesResponsibilities to Classes
1. System intelligence should be evenly distributed.
2. Each responsibility should be stated as generally as possible.
3. Information and the behavior that is related to it should reside within the same class.
4. Information about one thing should be localized with a single class, not distributed across multiple classes.
5. Responsibilities should be shared among related classes, when appropriate.
Example: Identifying ResponsibilitiesExample: Identifying Responsibilities
Narrative: SafeHome software enables the homeowner to configure the
security system when it is installed, monitors all sensors connected to the security system, and interacts with the homeowner through a keypad and function keys contained in the SafeHome control panel.
During installation, the SafeHome control panel is used to “program” and configure the system. Each sensor is assigned a number and type, a master password is programmed for arming and disarming the system, and telephone number(s) are input for dialing when a sensor event occurs.
Example Operations: Assign (belongs to Sensor) Program (belongs to System) Arm/Disarm (belong to System)
Example: CRC ResponsibilitiesExample: CRC Responsibilities
Example Attributes: sensor information = sensor number + sensor type + alarm threshold
class name: Sensor
class type: external entity
class characteristics: tangible, atomic, concurrent, guarded
responsibilities: collaborators:
keep sensor informationassign sensor informationsignal sensor event
[3] Identifying Collaborators[3] Identifying Collaborators
Collaborations represent requests from a client to a server in fulfillment of a client responsibility
One object collaborates with another if it needs to send a message
Relationships: is-part-of (classes that are contained within an
aggregate class as attributes)
has-knowledge-of (one class must acquire information from another)
depends-upon (dependency not covered by part-of or knowledge-of)
[4] Reviewing the CRC Model[4] Reviewing the CRC Model
1. All participants in the review (of the CRC model) are given a subset of the CRC model index cards.
2. All use-case scenarios (and corresponding use-case diagrams) should be organized into categories.
3. The review leader reads the use-case deliberately. As the review leader comes to a named object, she passes the token to the person holding the corresponding class index card.
4. When the token is passed, the holder of the class card is asked to describe the responsibilities noted on the card. The group determines whether one (or more) of the responsibilities satisfies the use-case requirement.
5. If the responsibilities and collaborations noted on the index cards cannot accommodate the use-case, modifications are made to the cards.
Example: CRC ReviewExample: CRC Review
Use-Case Narrative: The homeowner observes the control panel to determine if the
system is ready for input. If the system is not ready, the homeowner must physically close window/doors so that the ready indicator is present [a not ready indicator implies that a sensor is open].
When review leader comes to “control panel” token is passed to the person holding the control panel CRC card.
Phrase “implies that a sensor is open” means a responsibility must validate this.
The control panel CRC card has sensor as a collaborator
The token is next passed to the sensor CRC card.
CRC TipsCRC Tips
Don’t generate long lists of responsibilities. This is missing the point. The responsibilities should easily fit on a card.
The review stage is crucial. Spend a lot of time here.