Software

Composing Objects Principle

The principle states that classes should achieve code reuse through aggregation rather than inheritance. For example the Composite design pattern and the Decorator design pattern use this approach.

The idea here that concrete classes can delegate tasks for other concrete classes. Delegation will provide loser level coupling then inheritance. Hence, provide your system more flexibility.

Disadvantages of Composition:

The biggest drawback of composition is that you must provide implementations for all behavior without the benefit of inheritance to share code. This means that you might have very similar implementations across the classes.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.