Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

jamesjones21
jamesjones21
9,260 Points

Object Oriented Programming: Composition Over Inheritence

Hi,

I'm going through some of OOP stuff I have picked up from here an other stuff, I am looking over Composition, which means and object within an object.

Which then means the relationship between the both object is a HAS-A relationship.

I'm currently working on a scenario that looks at taking an outside object (Vehicle Catalogue) and which then gets instantiated into the Customer Class.

There I can then get information from the Vehicle Catalogue and gather information based on the Customer.

I think the link between the two objects is Composition Aggregation, which means one to many relationship.

I understand when to use Compostion and when to use Inheritence, but wondering how big of a deal it is to learn?

Kind regards,

James