Monday, 11 April 2016

How to describe Composition in OOPs ?


Composition
  • This is a stringer form of aggregation.
  • It expresses relationship between a ‘container’ and ‘contained’ or ‘part’.
  • The container is responsible for creation and deletion of its parts.

 












Composition example


In composition, the attribute is contained by value.

Composition = Aggregation with lifetime control

Shown  by filled diamond at the "owner" side

Lifetime control: Construction and destruction controlled by "owner" →  call constructors and destructors (or have somebody else do it)
Lifetime control implied.
Lifetime control can be transferred.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.