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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -