×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

One step up from dependency is association.

In an association, the state of the object depends on another object.
In an association we say that, as part of understanding the state of one object, you must understand the relationship with the second object. There are many types of association which model real-world relationships such as owns (John owns this car), works for(Pete works for Bill) and so forth.
In an association the two objects have a strong connection but neither one is a part of the other. The relationship is stronger than dependency; there is an association affecting both sides of the relationship.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / OO. I know the relationship between Composition and Inheritance. But I can't understand clearly about Aggregation, Association, and Dependency. Would you please help me clarify them? tks.
    • Yes, I'd like to know the answer. Somebody please help!
    • The simplest is dependency
      Dependency is where one object must know about another.
      In a simple dependency relationship all we know is that one object has knowledge of another. For example, in C++, if one class requires the inclusions of the header for another, that establishes a dependency.
    • My Answer
      Association: Models a semantic connection among classes

      Aggregation: A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts

      Composition:A form of aggregation with strong ownership and coincident lifetimes(The parts cannot survive the whole/aggregate)
    • One step up from dependency is association.
      In an association, the state of the object depends on another object.
      In an association we say that, as part of understanding the state of one object, you must understand the relationship with the second object. There are many types of association which model real-world relationships such as owns (John owns this car), works for(Pete works for Bill) and so forth.
      In an association the two objects have a strong connection but neither one is a part of the other. The relationship is stronger than dependency; there is an association affecting both sides of the relationship.
    • Aggregation models the whole/part relation.
      Objects are ofter made up of other objects. Cars are made up of steering wheels, engines,transmissions and so forth. Each of these components may be an object in its own right. The special association of a car to its component parts is known as aggregation.
    • 最后声明:我手头正好有一本书,我照抄的,希望对你有所帮助 :-)
    • 推荐一本好书 -- Beginning Object-Oriented Analysis and Design with C++, 作者 Jesse Liberty。ISBN 1-861001-33-9。 价格$48.95 CND or $34.95USD
      • 谢谢!我这就去借一本看看。
    • Recommend a very nice website - www.umlchina.com, there are tons of doucments and softwares about OOD, OOA, OOP, Pattern Design, UML and Pational Rose. most of them r pdf format, easy to be printed.
      • Thank you.
        • 你忘留电话了,打个电话过来吧
          • 昨天跟你家领导聊的太投入了,一放下电话,想起来了。给你发个邮件吧。