Please excuse the poor example/analogy, I'm only interested in the code sample.

I have a Dinner_Chair class (inherited from Chair class). It is as follows.

Dinner_Chair = class(Chair)
      theUser: Person;

            Back = new Back();
            Seat = new Seat();

I also have a simple Person class, that as you can see, is associated with the Dinner_Chair class.

My question is this. Because the Person class is not instantiated in the Dinner_Chair class, is this an example of aggregation?

This is to consolidate my understanding of entry level OOP relationships.


1 Answer 1


In code terms it could be aggregation but not necessarily. In the real world of dining chairs and people/diners, the relationship isn't aggregation because both objects can exist independently of each other.

The differentiation with regards to the code sample is whether a Dinner_Chair is a valid object without a Person.

Aggregation implies the Person is a required dependency of Dinner_Chair - i.e. Dinner_Chair isn't valid without a Person.

Association implies the Person is an optional dependency of Dinner_Chair - i.e. Dinner_Chair is valid without a Person.

  • Interesting. I missed that 'key' idea you've highlighted! Excellent. In my code sample, it supposes there must be a person associated with the dinner_chair, that is, upon dinner_chair instantiation. Because I have a separate Person class - and I may instantiate a new Person object at will - I guess this infers that it must be aggregation. Yes, this is not realistic, but I can see now that the dinner_chair requires a person, before it can be instantiated. Commented Mar 14, 2017 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.