Hi Design_Guru,
Could you give some java code example for the three types of relationships. It is confusing just reading text, with little code snippet may be i can understand better.
Thanks
Gobi
Hi Design_Guru,
Could you give some java code example for the three types of relationships. It is confusing just reading text, with little code snippet may be i can understand better.
Thanks
Gobi
Hi @Gobi,
Short answer, Association is established in the code as reference properties (class attributes), as in the case of Waiter and Order. ‘Dependency’ is realized in the code through a method parameter or a returned attribute from a method.
For detailed answer take a look here: Association vs Aggregation vs Composition in the code.
There a lot of examples of these relations in the case studies.
Regarding car parking object oriented design, code is a total garbage. Where did you implement parkingspot.getNumber() method? You totally forgot to put it there.
freeHandicappedSpotCount++ or some freeSpotCount is incremented whenever freespot is called. However freeSpotCount is not decremented when the new car parking takes place. Come on. What is the initial freeHandicappedSpotCount?