You are on page 1of 23

DOMAIN MODEL REFINEMENT

Relationships
Association
Aggregation Composition

Dependency Generalization Realization

Relationships: Association
Models a semantic connection among classes
Association Name

Professor

Works for

University

Association Class

Role Names

Professor
Employee Employer

University

Aggregation
Aggregation is a kind of association used to model whole-part relationships between things. The whole is called the composite.

Relationships: Aggregation
A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts Part

Whole

Student

Schedule

Aggregation

Relationships: Composition
A form of aggregation with strong ownership and coincident lifetimes
The parts cannot survive the whole/aggregate
Whole Part

Student

Schedule

Aggregation

1. Aggregation Vs Composition
UML aggregation is weak containment, usually implemented with pointers, and the symbol is an open diamond. Composition is strong containment, implemented by value, and the symbol is a filled diamond.

Aggregation Vs Composition
An aggregate object is one which contains other objects. For example, an Airplane class would contain Engine, Wing, Tail, Crew objects. Sometimes the class aggregation corresponds to physical containment in the model (like the airplane). But sometimes it is more abstract (e.g. Club and Members). The test for aggregation is to see if there is a whole/part relationship between two classes . A synonym for this is part-of.

Example: Multiplicity and Navigation


Multiplicity

Student

0..*

Schedule

Navigation

Relationships: Dependency
A relationship between two model elements where a change in one may cause a change in the other Non-structural, using relationship
Class
Client Supplier

Component

Package

Dependency relationship

Client

Supplier

ClientPackage

SupplierPackage

Dependency relationship

Relationships: Generalization
A relationship among classes where one class shares the structure and/or behavior of one or more classes Defines a hierarchy of abstractions in which a subclass inherits from one or more superclasses
Single inheritance Multiple inheritance

Generalization is an is-a-kind of relationship

Example: Single Inheritance


One class inherits from another
Ancestor
Account balance name number Withdraw() CreateStatement()

Superclass (parent)

Generalization Relationship

Checking

Savings GetInterest() Withdraw()

Subclasses

Withdraw()

Descendents

Example: Multiple Inheritance


A class can inherit from several other classes
FlyingThing
multiple inheritance

Animal

Airplane

Helicopter

Bird

Wolf

Horse

Use multiple inheritance only when needed, and always with caution !

Example: What Gets Inherited


GroundVehicle

Superclass (parent)

weight licenseNumber
register( )

owner 0..* 1

Person

generalization

Subclass

Car size

Truck tonnage getTax( )

Trailer

Class Diagram for the Sales Example


Sale

seller

buyer

item sold

shipping mechanism

Salesperson

Customer

Product

Vehicle

Corporate

Individual

Truck

Train

Effect of Requirements Change


Suppose you need a new type of shipping vehicle ...
Sale

seller

buyer

item sold

shipping mechanism

Salesperson

Customer

Product

Vehicle

Corporate

Individual

Truck

Train

Airplane

Change involves adding a new subclass

You might also like