Skip to main content

Class Attributes, Methods, and Relationships

Continue the order domain model by adding data and behavior to Order, then refine its relationship with order items.

Full lesson walkthrough in the selected color theme.

Starting Model​

Open the Order Domain Model class diagram. It already contains Order, Order Item, Product, and the first directed relationship.

Loading image...
Three core classes and the relationship from Order to its items

Select Order. In the properties panel, Class Attributes and Class Methods open dedicated collection editors.

Loading image...
Class attributes and methods are edited as independent collections

Class Attributes​

Open Class Attributes and add two rows:

  • orderNumber — unique order number, type String;
  • status — current order state, type String.
Loading image...
Each attribute has a name, description, and data type

Select Apply. The attributes, types, and descriptions immediately appear in their own section of the class on the diagram.

Loading image...
The class data structure is shown directly inside the element

Class Method​

Open Class Methods and add createOrder. Describe its purpose and set its return type to void.

Loading image...
The method has a name, description, and return type

After applying the change, the method appears in its own section below the attributes. The class now captures both data and behavior.

Loading image...
The class is divided into description, attributes, and methods

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.

Loading image...
The relationship is a composition from one order to 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.

Loading image...
Order captures data and behavior while composition expresses ownership of items

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.