These terms signify the relationships between classes. These are the building blocks of object oriented programming and very basic stuff. But still for some, these terms look like Latin and Greek. Just wanted to refresh these terms and explain in simpler terms.
Association
Association is a relationship between two objects. In other words, association defines the multiplicity between objects. You may be aware of one-to-one, one-to-many, many-to-one, many-to-many all these words define an association between objects. Aggregation is a special form of association. Composition is a special form of aggregation.
Example: A Student and a Faculty are having an association.
Aggregation
Aggregation is a special case of association. A directional association between objects. When an object ‘has-a’ another object, then you have got an aggregation between them. Direction between them specified which object contains the other object. Aggregation is also called a “Has-a” relationship.
Composition
Composition is a special case of aggregation. In a more specific manner, a restricted aggregation is called composition. When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition.
Example: A class contains students. A student cannot exist without a class. There exists composition between class and students.
Difference between aggregation and composition
Composition is more restrictive. When there is a composition between two objects, the composed object cannot exist without the other object. This restriction is not there in aggregation. Though one object can contain the other object, there is no condition that the composed object must exist. The existence of the composed object is entirely optional. In both aggregation and composition, direction is must. The direction specifies, which object contains the other object.
Example: A Library contains students and books. Relationship between library and student is aggregation. Relationship between library and book is composition. A student can exist without a library and therefore it is aggregation. A book cannot exist without a library and therefore its a composition. For easy understanding I am picking this example. Don’t go deeper into example and justify relationships!
Abstraction
Abstraction is specifying the framework and hiding the implementation level information. Concreteness will be built on top of the abstraction. It gives you a blueprint to follow to while implementing the details. Abstraction reduces the complexity by hiding low level details.
Example: A wire frame model of a car.
Generalization
Generalization uses a “is-a” relationship from a specialization to the generalization class. Common structure and behaviour are used from the specializtion to the generalized class. At a very broader level you can understand this as inheritance. Why I take the term inheritance is, you can relate this term very well. Generalization is also called a “Is-a” relationship.
Example: Consider there exists a class named Person. A student is a person. A faculty is a person. Therefore here the relationship between student and person, similarly faculty and person is generalization.
Realization
Realization is a relationship between the blueprint class and the object containing its respective implementation level details. This object is said to realize the blueprint class. In other words, you can understand this as the relationship between the interface and the implementing class.
Example: A particular model of a car ‘GTB Fiorano’ that implements the blueprint of a car realizes the abstraction.
Dependency
Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the same vice-versa. When one class contains the other class it this happens.
Example: Relationship between shape and circle is dependency.
原文地址:
http://javapapers.com/oops/association-aggregation-composition-abstraction-generalization-realization-dependency/
分享到:
相关推荐
Association, Aggregation and Composition 的区别 在 Java 应用程序开发中,理解 UML 类图元素及其与 Java 的映射关系是非常重要的。其中,Association、Aggregation 和 Composition 是三个常见的 UML 元素,它们...
Aggregation and composition Generalization and inheritance Abstract class Interface © Pearson Education 2007 Appendix (Maciaszek - RASD 3/e) 3 Object has State Behavior Identity ...
Aggregation Aggregation Aggregation 适合聚类使用!有多类簇
kylin-mondrian-interaction, 关于Apache与 Pentaho Mondrian 交互的一些信息 Interaction InteractionKylin与 Mondrian 与Saiku的交互包括补丁和 jars 。预安装要求你应当能够运行 Kylin,构建和创建一个 Cube多维...
### 关联、聚合(Aggregation)以及组合(Composition)的区别 在面向对象设计中,类之间的关系是非常重要的概念。这不仅有助于理解系统架构,还能帮助开发者更好地组织代码。本篇文章将详细探讨关联、聚合...
关联关系(Association) 聚合关系(Aggregation) 组合关系(Composition) 依赖关系(Dependency) 泛化关系(Generalization) 实现关系(Realization) 2、设计原则 开闭原则 里氏替换原则 依赖倒置原则 单一职责原则 接口...
### 机器学习技法课之Aggregation模型 #### 一、Aggregation模型概述 Aggregation模型是一种重要的机器学习技术,主要用于组合多个弱学习器以形成一个更强大的预测模型。这一技术的核心在于通过各种策略来整合不同...
Edzer Pebesma (2018). Numerical “map overlay” ...spatial data, so that any spatial properties can be used to define an aggregation predicate, and any R function can be used as aggregation function.
Unsupervised Part-based Weighting Aggregation of Deep Convolutional Features for Image Retrieval.pdf
在本文中,我们将深入探讨GXT组件的使用,特别是关于Aggregation Grid的教程。GXT是Sencha提供的一款强大的JavaScript库,专为构建企业级Web应用程序而设计,它提供了丰富的UI组件和数据网格功能。Aggregation Grid...
《跨尺度成本聚合码》(Cross-Scale Cost Aggregation Code)是实现立体匹配算法CSCA(Cross-Scale Cost Aggregation)的一种软件实现。立体匹配是计算机视觉领域的一个重要研究方向,其目标是通过分析图像对来计算...
在UML类图中,常见的有以下几种关系: 泛化(Generalization), 实现(Realization),关联(Association),聚合(Aggregation),组合(Composition),依赖
标题"tcp.tar.gz_aggregation_aggregation in ns2_ns2_ns2 aggregation_tc"暗示了我们即将探讨的是NS2中TCP协议与802.11 MAC层的聚合(aggregation)功能,以及可能涉及的TCP分片重组(fragment retransmission)...
Applications need the N-dimensional generalization of these operators. This paper defines that operator, called the data cube or simply cube. The cube operator generalizes the histogram, cross-...
UML类图几种关系的总结: 常见的有以下几种关系: 泛化(Generalization), 实现(Realization),关联(Association),聚合(Aggregation),组合(Composition),依赖(Dependency)
### HP Auto Port Aggregation (APA) Release Note #### HP APA Overview for HP-UX 11iv1 **Auto Port Aggregation (APA):** Auto Port Aggregation is a feature designed to provide high-speed, fault-...
使用matlab自己编辑的基于模版大小实现均值滤波,并且将模版均值赋予新的矩阵,生成灰度图像。
EventAggregation
We study a new aggregation operator for gradients coming from a mini-batch for stochastic gradient (SG) methods that allows a significant speed-up in the case of sparse optimization problems. We ...
LTE-Advanced技术中的载波聚合(Carrier Aggregation)是4G网络技术中的一项重要进步,它极大地提高了数据传输速率,改善了频谱效率,特别适合于高密度的用户部署环境。载波聚合技术的核心在于将多个载波(频段)...