Class Attributes, Methods, and Relationships
Continue the order domain model by adding data and behavior to Order, then
refine its relationship with order items.
Starting Model
Open the Order Domain Model class diagram. It already contains Order,
Order Item, Product, and the first directed relationship.
Select Order. In the properties panel, Class Attributes and Class
Methods open dedicated collection editors.
Class Attributes
Open Class Attributes and add two rows:
orderNumber— unique order number, typeString;status— current order state, typeString.
Select Apply. The attributes, types, and descriptions immediately appear in their own section of the class on the diagram.
Class Method
Open Class Methods and add createOrder. Describe its purpose and set its
return type to void.
After applying the change, the method appears in its own section below the attributes. The class now captures both data and behavior.
Composition and Multiplicity
Select Contains Items and set Class Relationship Type to Composition:
the items are parts of the order and are owned by it.
Set source multiplicity to 1 and target multiplicity to 1..*. One order
therefore contains one or more items.
Clear the selection to see the complete Order class, composition diamond, and
both multiplicities. Product remains separate until the next model extension.
Chapters
00:00— lesson objective;00:05— selecting Order;00:10— attribute editor;00:12— first attribute;00:20— second attribute;00:28— applying attributes;00:34— method editor;00:47— applying the method;00:52— selecting the relationship;00:55— relationship type;01:05— source multiplicity;01:16— target multiplicity;01:24— final model.
Previous lesson: First Class Diagram.
Next lesson: Expand the Order Domain Model.