oop - Composition vs Aggregation -
let have car class , paint class(which consists of different colors). in terms of object oriented design can relation between these 2 classes composition or aggregation. first thought composition , thought aggregation since if car class destroyed paint can exist independently. thinking right on here?
i depends on context of model. paint class represent? "a paint job specific car"? if so, part-of car , considered composition. if paint independent concept, , instance can applied multiple cars, car has-a paint instance, , considered aggregation.
Comments
Post a Comment