Skip to content

Interfaces vs Abstract Class vs Composition

When to Prefer inheritance over Composition?

If A is B then Prefer inheritance , If A has B then Prefer Composition

When to Prefer Abstract Class vs Interface?

Use abstract clases and inheritance if you can make the statement “A is a B”. Use interfaces if you can make the statement “A is capable of [doing] as”, or also, abstract for what a class is, interface for what a class can do.