Classes and Relationships
Behavioral
Structural
Objective
- Design classes, attributes, and operations.
- Understand the different relationships between classes.
- Map between use cases, data flows, and classes.
- Round-trip code generation.
Classes
Domain Model
Entities and Relationships
More on ERD in CMPS 351: Fundamentals of Database Systems.
Encapsulation
Attributes
Exercise 1
Create a class diagram with enumerations, classes, and their attributes.
Relationships
Generalization
Specialization. «is a». Inheritance
Association
Aggregation
«has a»/«is part of», «contains»
Composition
Stronger version of aggregation. The lifetime of the part is dependent on the whole. The lifecycle of the part is managed by the whole.
Multiplicity
Realization
Interfaces. Abstract classes.
Dependency
Exercise 2
Add relationships to the classes from Exercise 1.
Operations
Exercise 3
Add operations to the classes from Exercise 2. Create at least one interface.
Code Generation
Follow the 6 Code Generation guide to learn more about round-trip engineering.
Exercise 4
Generate Java code for the classes from Exercise 3.
Coupling
Cohesion
Explore the 10 SOLID + GRASP guide to learn more about the SOLID design principles.
Entity-Control-Boundary
Entity-Control-Boundary (ECB) pattern is a simplification of the Model-View-Controller (MVC) pattern. ECB partitions the system into three types of classes: entities, controls, and boundaries. Whereas MVC is used for user interfaces, ECB is used for systems. An Entity is not a Model, but a class that represents a concept in the system. A Control is not a Controller, but a class that coordinates the system. A Boundary is not a View, but a class that interacts with the user.
| Actor | Entity | Control | Boundary | |
|---|---|---|---|---|
| Actor | ||||
| Entity | ||||
| Control | ||||
| Boundary |
Structure
classes.vpp
Resources
- Visual Paradigm: UML class diagram tutorial (opens in a new tab), What is class diagram? (opens in a new tab), Class diagram (opens in a new tab), Class diagram tutorial (opens in a new tab), How to link with classes in use case flow of events (opens in a new tab)
- Information hiding (opens in a new tab)
- What are the six types of relationships in UML class diagrams? (opens in a new tab)
- UML class diagram relationships explained with examples (opens in a new tab)
- Generate class diagram from existing classes (opens in a new tab)
- Multiplicity (opens in a new tab)
- The Entity-Control-Boundary Pattern (opens in a new tab), Guideline: Entity-Control-Boundary Pattern (opens in a new tab)
- Principle of least privilege (opens in a new tab)
- UML diagrams (opens in a new tab)