4. Domain Models Flashcards
Goals of Domain Models
▪ Illustrates noteworthy concepts / terms / objects in an application domain
▪ Source of inspiration for (later) object-oriented design of application logic
Domain Models vs. Design Models
▪ We create domain models in order to understand the application domain
▪ We create design models in order to express how our solution shall work
What is the key challenge in Domain Models?
Key challenge is understanding all of the domain’s entities and their relationships,
i.e. not missing anything important
What is the key challenge in Design Models?
Key challenge is engineering a solution that enables efficient implementation, execution and
maintenance, i.e. creating an efficient design
A domain model is typically expressed as a UML class diagram showing
▪ Conceptual classes
▪ Associations between conceptual classes
▪ Attributes of conceptual classes
Strategies for Identifying Conceptual Classes
in Complex Domain Models
Extract noun phrases
Use a category list
Reuse or modify existing models
Describing the Application Domain (“Real World”)
Use the existing terminology
Exclude irrelevant or out-of-scope aspects
Don’t add concepts to the model if they don’t exist in the application domain
Adding Associations to Domain Models
An association between two classes indicates the presence of a relevant, memorable relationship between instances of those classes.
Using and Interpreting Associations
in Domain Models
▪ Domain model associations are bidirectional
▪ Associations should be labeled with verb phrases connecting the class names
▪ Multiple associations can connect classes to symbolize different relationships
▪ An association can be reflexive, i.e. relating instances of the same class
Using and Interpreting Associations
in Domain Models
▪ Domain model associations are bidirectional
▪ Associations should be labeled with verb phrases connecting the class names
▪ Multiple associations can connect classes to symbolize different relationships
▪ An association can be reflexive, i.e. relating instances of the same class
Aggregation
▪ Aggregation describes a “contains” relationship
Composition
Composition describes a “consists of” relationship implying that
▪ A part instance (e.g. Square) belongs to only one composite instance (e.g. Board) at a time
▪ Any part must belong to a composite at any time (“no loose Fingers”)
Adding Attributes to Domain Models
▪ An attribute is a logical data value of an object.
▪ Attributes are typically primitive data types or trivial data structures
▪ Do not include attributes that are merely technical IDs or foreign keys
▪ Do not include derived attributes, unless their omission would be confusing
▪ Associations may have attributes just like classes do