OOPortal OOPortal


Sequence Diagram   «Prev  Next»
Lesson 7 Discovering attributes
ObjectiveIdentify ways to derive attributes and extend the sequence diagram to support Data access

Identify Ways to discover Attributes

Information maps to attributes

Every piece of information used by a system must be defined as an attribute. Every attribute must be owned by an object. Even if an attribute is derived and is never actually stored, some object has to own the rules for deriving it.

Define an attribute with the following format:

  1. Visibility: required before code generation
  2. Class attribute: optional
  3. Derived attribute indicator: optional
  4. Attribute name: required
  5. Data type: required
  6. Assignment operator and default value: optional
  7. Constraints: optional

Discovering Attributes
Object Model Information

Operation parameters and returns

Every argument in an operation must have a source. Does the object that initiates the event own the data? If it does not own the data, then where does it get the data? Look in the class diagram and find the class that should own the data. Update the sequence diagram to show how the initiating object obtained the data from the owning object.

Example: Expanding a sequence diagram for a parameter

Below is the class diagram segment for this example project Purchase Seats use case:

Initial sequence diagram for the Purchase Seats use case

The initial sequence diagram for the Purchase Seats use case:
Example of expanding a sequence diagram for a parameter

Operation returns

The same logic applies to operation returns. Does the responding object own this data? If it does not own the data, then where does the object get it? Does the object derive the data using another of its own operations? Does the object have to look up the value using other objects? Update the sequence diagram to add the object(s) that own the data and show how the original object obtained the data.

An example of expanding a sequence diagram for a return

Using the course project as an example, when a customer wants to buy show seats, he or she must provide a price type for each seat in order for the system to know which price to charge, that is, adult, student, senior citizen, or child. For instance, I could buy four tickets, two for adults and two for children:

The Customer is the only object that knows what price type should be used to price each seat.

To find the price for ShowSeat, ShowSeat must ask for the price from PriceTier. When asking for the price, ShowSeat must provide a price type so that PriceTier can decide which price to return.

Example of finding the source of a return value

Each time you add a new interaction, you iterate through the modeling process:
  1. Evaluate the class diagram to find the objects that participate in the interaction.
  2. Add the new object(s).
  3. Identify the new events.
  4. Reevaluate the purpose of the participating objects.
  5. Convert the events to operations.
  6. Convert the information to attributes.
  7. Assign ownership of the attributes.
  8. Repeat until all parameters and returns are accounted for.

Discovering Attribute Exercise

Click the Exercise link below to extend a course project sequence diagram to add data sources.
Discovering Attribute - Exercise