Ad Code

Composition in OOP ?

In composition if the whole object is destroyed than its composed objects also destroyed, then why we need to separate small objects to form a bigger object, se can also makes attributes and behavior into one main object instead of smaller objects. 

OOP paradigm is a mapping of real life objects with which the concept of composition comes. A real-world example of composition may be seen in the relation of an automobile to its parts, specifically: the automobile 'has or is composed from' objects including steering wheel, seat, gearbox and engine.
When, in a language, objects are typed, types can often be divided into composite and non composite types, and composition can be regarded as a relationship between types: an object of a composite type (e.g. car) "has an" object of a simpler type (e.g. wheel).
Reactions

Post a Comment

0 Comments