Skip to main content
OBJECT-ORIENTED-PROGRAMMING5 MIN READ

Prefer composition when roles combine

Choose composition over inheritance when behaviors vary along independent axes.

The access model has independent variation axes, which makes composition a better fit than more subclasses.

Read the full lesson

Sign up free — one personalized lesson every day, matched to your role and goals.

Already have an account? Sign in

← Back to library
Contact us