stephenson college dp 98 1 associations & aggregations by derek peacock
TRANSCRIPT
Stephenson College DP 98 1
Associations & Aggregations
by Derek Peacock
Stephenson College DP 98 2
Associations
One to One One to Many Many to Many
0..1 10
Associates with
Stephenson College DP 98 3
Uni-Directional Association
Switch Light bulbControls
ActorServer
Stephenson College DP 98 4
Application Associations
Lecturer UnitsTeaches
Contract
Teaches to
*
Classroom
Taught in
*
*
Stephenson College DP 98 5
Containment v. Containers
One object composed of fixed no of other objects
Can not exist without its components
e.g. a Car is composed of and engine, four wheels
One object may contain a variable no of other objects
Can exist independently
e.g. a Car Boot may contain some luggage, some books, some wine
Stephenson College DP 98 6
Composition (of parts)
Clock
Hand Face Body
2
Battery
Stephenson College DP 98 7
Aggregation
Parts can have independent life outside aggregation
e.g. a battery as part of a clock, as opposed to the hands of the clock
Stephenson College DP 98 8
A Checkout Aggregation
Checkout
Barcodereader
Weighing scale
Till
CustomerQueue
Stephenson College DP 98 9
The Solent Hotel
Has 5 function rooms @ £200 Has 40 bedrooms 10 single bedrooms @ £40 30 double rooms @ £55 One set of presentation equipment Customers name and payee recorded
Stephenson College DP 98 10
UML Class Diagram (1)
Hotel
Single Room
DoubleRoom
FunctionRoom
Equipment
Is in0..1
10 30 5
Stephenson College DP 98 11
UML Class Diagram (2)
Single Room
DoubleRoom
FunctionRoom
Room CustomerBooks
0..1