Skip to main content

Class Model

This document was generated using AI assistance

Content may include inaccuracies, outdated information, or technical errors. Users are advised to cross-check critical information before implementation.

A class model describes the data of a system: classes, their attributes, the references between classes and the data types the values come from. Multiplicities, value ranges and string patterns are set here as well.

A class model: two classes and a reference from one to the other

Create two models

Create a model Data Types of the type ClassModel and a second model Sample. The first holds a vocabulary of data types, the second the classes. Other models can then use the same types.

Data types are model elements just like classes, so a model may consist of types alone.

The vocabulary of types

Add to Data Types:

  • string type String, boolean type Boolean, UUID type UUID;
  • numeric type Integer with fractionDigits 0;
  • numeric type UnsignedInt with size 32 and minInclusive 0;
  • temporal type Date with instantUnits Year, Month, Day.

Add to Sample the two types only it needs: numeric Money (totalDigits 19, fractionDigits 4, minInclusive 0) and enumerated Color with the literals Red, Green, Blue, Black.

Classes

Add four classes to Sample. A class owns properties, and a property is either an Attribute with a data type or a Reference to another class. Both have a multiplicity.

ClassProperties
UserfirstName, lastName, birthDate [0..1], email [1]
OrderdeliveryAddress String [1]
OrderItemquantity UnsignedInt [1], price Money [1]
Productabstract, name String [1]

Add Book with the attribute author and Pen with the attribute color. Draw Generalization from each to Product.

References

OwnerReferenceTargetKindMultiplicity
OrderuserUserAssociation[1]
OrderitemsOrderItemComposition[0..*]
OrderItemorderOrderAssociation[1]
OrderItemproductProductAssociation[1]

Set items and order as opposite to each other - on the diagram the two references become the two ends of one edge.

Textual representation

Open the model as text. This is the same model written as source: renaming a class in the text renames it on the diagram.

classModel Sample

class Order {
attribute deliveryAddress String
reference user User
composition items OrderItem [0..*] opposite order
}

abstract class Product {
attribute name String
}

class Book extends Product {
attribute author String
}

enumerated Color {
Red
Green
Blue
Black
}