简体   繁体   中英

What is the difference between association and dependancy relationship?

What's the difference between Association and Dependency? Aren't they both the same thing? as if class A is associated with B then Class A is dependent on B ie. there's a dependency between A and B.

When you are speaking in UML terms, an association allows one object to send a message to another object by instantiating it.A dependency, on the other hand, means that one objects relies on another object and it might change if the other object changes, however there are no instances of those to objects.

http://en.wikipedia.org/wiki/Dependency_(UML)

Similar topic in SO: Does an association imply a dependency in UML?

In the above post, there's a reference to the UML's Superstructure document:
OMG Unified Modeling LanguageTM (OMG UML) Superstructure (PDF format)

Very technical but can be a good read as well.

Dependency relationship does not require direct communication between two elements. It just means that one object relies on a fact that another object exists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM