CSE Roadmap

Core tier · about 2 hours · 7 parts

Part 3 of 7 · 1 min read

Links between classes

Five kinds of line, five kinds of meaning.

Lines show how classes depend on each other. (Level 1 module 6 studies these in depth. This is enough to draw and read them.)

Link Meaning Text sketch
Association One object knows another Booking --> Room
Aggregation A whole has parts that can live on their own Building o--> Room
Composition A whole owns parts that die with it Booking *--> TimeSlot
Inheritance A class is a kind of another Car --|> Vehicle
Implementation A class promises an interface FlatRate ..|> PricingStrategy
Dependency One class uses another briefly BookingService ..> Booking

Numbers on the ends say how many. Room 1 --- * Booking reads: one room has many bookings. Over a day, a room may have up to 16 bookings of one block each (made-up numbers from module 2), and a booking has exactly one room.

A quick test for a link: if deleting the whole also deletes the part, use composition. If the part can be moved to another whole, use aggregation.

Check yourself: 1. What does Room 1 --- * Booking say? 2. Which link means "is a kind of"? 3. Is TimeSlot inside Booking composition or aggregation?