1. Dependency:
A dependency is a weak relationship between two classes.
In this example, there is dependency between Point and LineSegment, because LineSegment's draw() operation uses the Point class.
It indicates that LineSegment has to know about Point, event if it has no attribute of that type.
2. Association:
Association is a relationship where all objects have their own lifecycle and there is no owner.
Let's make an example of Teacher and Student. Multiple students can associate with single teacher, and single student can associate with multiple teachers.
But there is no ownership between the objects and both have their own lifecycle. Both can create/delete independently.
1> Bi-directional association:
Associations are bi-directional by default, so both classes know about each other and about the relationship between them.
In the diagram below, any instance of Student can have 1~* Teachers, and any instance of Teacher can have 1~30 Students.
2> Uni-directional association:
Association can also be uni-directional, where one class knows about the other class and the relationship but the other class does not.
In the diagram below, Customer class knows about any number of Products purchased, but the Product class knows nothing about the Customer.
Pruduct class doesn't even know about the existence of Customer class.
3. Aggregation: ("has-a" relationship)
Aggregation is a specialized form of Association where all objects have their own lifecycle, but there is ownership and child object cannot belong to another parent object[1].
Association differs from Aggregation only in that Association does not imply any containment.
A single CPU cannot belong to multiple computers, but if we dismantle the computer, the CPU will not be destroyed.
4. Composition: ("is-a" relationship)
Composition is again a specialized form(strong type) of Aggregation and we can call this a "death" relationship. It is a strong type of aggregation.
Child object doesn't have its own lifecycle. And if parent object is deleted, all child object will also be deleted.
Let's take agagin an example of house and rooms. House can contain multiple rooms, there is no independent lifecycle of room.
5. Additional knowledge points:
1) Generally, it is better to use attributes only for types you would not draw on the diagram, such as primitive types.
Diagram below is deprecated.
Diagram below is encouraged.
2) Sample
[1]: There are some debates upon the defination of Aggregation. Please refer to Reference Links(1)
Reference Links:
1) http://stackoverflow.com/questions/885937/difference-between-association-aggregation-and-composition
2) http://stackoverflow.com/questions/1874049/uml-arrows-pointers-explanation/2293763#2293763
3) http://stackoverflow.com/questions/15487372/bi-directional-and-uni-directional-associations-uml
4) http://www.classdraw.com/help.htm
5) http://msdn.microsoft.com/en-us/library/dd409416(v=vs.100).aspx
相关推荐
依赖注入:Dependency injection-英文书签文字版 全面讲解Spring中的依赖注入,是英文的文字版,带书签
数据库管理系统概述英文版课件:8 Functional Dependency and Normal Forms.ppt
1: WHY DEPENDENCY INJECTION? 2: DEPENDENCY INJECTION IN JAVA 9 3: DEPENDENCY INJECTION WITH SPRING 4: DEPENDENCY INJECTION WITH GOOGLE GUICE 5: SCOPES 6: ASPECT-ORIENTED PROGRAMMING AND INTERCEPTORS 7...
dpkg: dependency problems prevent configuration of mysql-community-client: mysql-community-client depends on libaio1 (>= 0.3.93); however: Package libaio1 is not installed. dpkg: error processing ...
在UML类图中,常见的有以下几种关系: 泛化(Generalization), 实现(Realization),关联(Association),聚合(Aggregation),组合(Composition),依赖(Dependency) 泛化(Generalization) 【泛化关系】:是一种...
This practical guide focuses on the variety of problems and issues which occur during the conception and development phase, with the aim of making dependency management as effortless and painless as ...
依赖检查器Dependency Checker SonarQube插件
mvn se.vandmo:dependency-lock-maven-plugin:lock将创建一个dependencies-lock.json文件。 然后,您应该将该文件提交给您选择的源控件。 如果某些依赖项是同一多模块项目的一部分,则您可能希望这些依赖项与锁定...
资源介绍:Dependency Walker(依赖项查看器)是一款强大而实用的免费模块依赖性分析工具,专为Windows系统打造,旨在帮助开发者和系统管理员轻松解析和查看应用程序或DLL文件的依赖关系。 Dependency Walker通过...
Deep Semantic Analysis: from Dependency Tree to Dependency Graph
Dependency Injection Principles, Practices, and Patterns teaches you to use DI to reduce hard-coded dependencies between application components. You'll start by learning what DI is and what types of ...
资源分类:Python库 所属语言:Python 资源全名:dependency-injector-4.1.2.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
类图中的关系:1:一般化(Generalization)关系2:关联(Association)关系2.1:聚合(Aggregation)关系2.2:合成(Composition)关系3:依赖(Dependency)关系
python库。 资源全名:dependency_injector-3.24.1-cp36-cp36m-win32.whl
在maven中配置的阿里云仓库无法下载com.aspose:aspose:jar:19,所以自己找的资源,很麻烦,为了方便兄弟们给你们了。
资源分类:Python库 所属语言:Python 资源全名:dependency_injector-3.26.0-cp35-cp35m-win_amd64.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
支持四类断言: Dependency , Inheritance , Composition和Mixin 。 :information: 退房的部分看到的典型应用案例的一些例子。 安装 :computer_disk: 只需在phpat即可: composer require --dev phpat/phpat ...
This book is for professional Java developers who are interested in dependency injection, modern Java coding practices and who want to tackle complexity with a simple, powerful and high-quality ...
资源来自pypi官网。 资源全名:dependency-injector-4.30.0.tar.gz