Advertisement Jump to content
Sign in to follow this  
swinchen

Association, Aggregation UML question...

This topic is 4899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


class foo
{
  private:
    int x,y,z;
};

class bar
{
  private:
    foo* m_fooPtr;
  public:
    void setFooPtr(foo *p_fooPtr) { m_fooPtr = p_fooPtr; }
};


Although incomplete, is the above an example of aggregation or association? class bar does not instantiate an instance of class foo, but it does contain a pointer to an instance. Thanks! Sam

Share this post


Link to post
Share on other sites
Advertisement
Association is a natural relationship between two things. Aggregation is a whole part relationship where on one object is a component of another. Aggregation can therefore be seen as a type of association. As there is a pointer involved there is minimally a type of association involved. There may or may not be an aggregation relationship invovled. True you can swap out parts with just a function call, and that usually points to a non-aggregation relationship, however there are systems where parts of an aggregate can be dynamically replaced. For an example, a keyboard may be seen as an aggregate component of a computer, but a keyboard can be replaced. Of course, it's weakened by the fact that foo has no relation linking to the bar object. So most likely there is a non-aggregation relationship involved.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!