Composition vs Inheritance

Composition:

  1. It is a smaller pieces to create a big.

  2. Defined as What it has.

Composition

Inheritance:

  1. It is that a super class is that extended to smaller pieces that add or override things.

  2. Defined as What it is.

  3. Tightly coupled, less code reusable. If any change in Base class will be useful or it may leads to code breakage.

  4. Hierarchy issues.

Inheritance

Last updated

Was this helpful?