6 Classes & Relationships

Classes and Relationships

Objective

  1. Design classes, attributes, and operations.
  2. Understand the different relationships between classes.
  3. Map between use cases, data flows, and classes.
  4. 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.

ActorEntityControlBoundary
Actor
Entity
Control
Boundary

Structure

      • classes.vpp
  • Resources