3

I've a question regarding the following diagram

enter image description here

My Qustion is in the relation between driver - Car and Passenger and Cars.

1- The * at driver end means that a car can be driven by many drivers, which is a relationship between the both classes at the lifetime of the system.

2- In the other case the relation ship between car and passengers are realtime relation ship, that at maximum only 0-7 passengers can be on the same car.

Did i get something wrong? How should i think about the relationships, is it realtime relationship between objects or relationship on the lifetime of the car

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
Omar Amin
  • 51
  • 8
  • 1
    You really should accept an answer to reward Geert or Thomas for taking the time to answer your question. Both are good answers, so choosing is tough. – Jim L. Dec 13 '15 at 22:40

2 Answers2

4

That actually looks like nonsense :-)

It means that a Driver operates 1 or more Cars. Multi-tasking might be some new capability of human beings (I doubt that). So driving two cars the same time will be tough, but then * cars?

The drawback with such class diagrams is that you can not see what kind of relation is meant. I assumed operates but it may well mean owns. A role name would clarify this ambiguity.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • Regarding the relation between driver and car, i assumed that it states that a driver is permitted to drive 1 or more cars, and each car can be driven by many drivers, unfortunately the reference mentioning the above diagram, doesn't provide any details if you can recommend resources that i can know more about class diagrams and design decisions that would be a great help – Omar Amin Dec 07 '15 at 21:36
  • Hard to recommend anything. I guess that UML for Dummies is stil a good one. You need to add a role name `permittedCar` on the `Car` side. That would have clarified the use of the association. And near the `Driver` there should be a `driver` role. – qwerty_so Dec 07 '15 at 22:04
2

Both current as historical relations can be expressed using associations.

In the case of Driver the current driver, and everyone who ever drove the car can be expressed using two different associations.

A Car can only have one CurrentDriver, and a Driver can only drive one Car at a time, but there can be many HistoricalDrivers who may have driven many different Cars over time.

Car-Driver Associations

The fact that you model Engine and Wheel as aggregations somewhat surprises me. An aggregation is in fact a shared AggregationKind, and I've never seen an Engine or a Wheel being part of two cars at once. I don't really see a reason why you would not use compositions here.

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
  • Plus adding the spare wheel is also funny. – qwerty_so Dec 07 '15 at 08:43
  • Regarding the aggregation relationship, the source says that as it can be replaced with other engines then it's not a composition relationship, the same source models the relationship between car and body as composition as body can't be replaced – Omar Amin Dec 07 '15 at 21:04
  • That is simply not true. UML 2.5 says the following about Composite AggregationKind: `NOTE. A part object may (where otherwise allowed) be removed from a composite object before the composite object is deleted, and thus not be deleted as part of the composite object.` So even with a composition you can remove an engine from one car and add it to another. – Geert Bellekens Dec 07 '15 at 21:20
  • I always found the difference quite subtle for real world exampled. A wheel can well live on its own and be used on different cars (the motor equally but not so easy to change). But menu positions composed from ingredients are composed and will not live on their own (in a computer environment; but in reality the still can). So it's more a memory management hint that object can/should be destroyed once they loose contact. – qwerty_so Dec 07 '15 at 22:09
  • Thanks for your effort – Omar Amin Dec 14 '15 at 00:12