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/
分享到:
相关推荐
#### 抽象(Abstraction) 在软件工程中,抽象是指从现实世界中提取关键特征,忽略非本质细节的过程。通过抽象,可以将复杂的问题简化为更易于理解和管理的形式,例如,将一个复杂的系统分解为多个模块或组件。 ###...
c语言盒子接球游戏源码
YOLOv8-streamlit-app软件,使用yolov8做的物体识别语义分割姿态检测,使用streamlit做的显示界面。下载即可运行,可做毕业设计。
MATLAB与计算物理课程 (第十周)第三章线性方程组的迭代法 共70页.pptx
在线日语培训平台 SSM毕业设计 附带论文 启动教程:https://www.bilibili.com/video/BV1GK1iYyE2B
c语言学生信息系统
Java大学生体质检测管理系统源码 大学生体质管理平台源码 源码描述 作为对大学生健康的监测的信息系统,其主要的工作是对相关数据的收集预测和给予正确的评价。 因此,该系统的设计目标则主要包括以下几个方面: 1)可应用于对学生相关健康数据的收集、存储、传递、维护和加工; 2)通过系统可对学生的相关身体健康情况进行科学的分析,并给予学生老师给出比较客观的评价指标。 3)具有一定的延展性可根据体育教学的需要,添加其他功能模块的系统。
技术资料分享DHT11很好的技术资料.zip
JNI 简介与实现
# 基于PyTorch框架的医学图像分割系统 ## 项目简介 本项目是一个基于PyTorch框架的医学图像分割系统,旨在利用深度学习模型对医学图像进行精确分割。系统中包含了用于图像分割的UNet模型,以及用于处理医学图像数据集的脚本和工具。项目还包含了用于训练模型的脚本,以及用于评估模型性能的指标计算和可视化工具。 ## 主要特性和功能 1. UNet模型实现项目中使用了UNet架构,用于对医学图像进行分割。该模型可根据不同的backbone(如VGG或ResNet)进行初始化,并支持冻结和解冻backbone的参数,以适应不同的训练需求。 2. 医学图像数据集处理项目提供了处理医学图像数据集的脚本,包括从原始数据中提取标注信息、生成训练、验证和测试集,以及进行数据增强和预处理等操作。
SQLite数据库工具
3d打印机,Prusa3D
c语言五子棋源码
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
# 基于Spring Boot和MyBatis的宿舍管理系统 ## 项目简介 本项目是一个基于Spring Boot和MyBatis框架开发的宿舍管理系统,旨在为学生、宿管和后勤人员提供一个高效的管理平台。系统支持用户管理、房间管理、楼宇管理、维修申请等功能,并具备人性化的宿舍分配和可视化的账单管理。 ## 项目的主要特性和功能 1. 用户管理系统中的用户分为学生、宿管和后勤三类,每类用户拥有不同的操作权限。 2. 房间管理支持房间的创建、删除、更新和查询操作,以及房间容量的调整。 3. 楼宇管理支持楼宇的创建、删除、更新和查询操作,以及楼宇入住率和性别信息的统计。 4. 维修申请学生可以提交维修申请,宿管和后勤人员可以管理和处理这些申请。 5. 账单管理支持账单的创建、删除、更新和查询操作,以及Excel文件的上传和数据导入。 6. 宿舍分配系统提供人性化的宿舍分配功能,支持根据学生的意向进行分配。
下载解压后,得到一个tcping.exe ,将tcping.exe 放到C盘Windows路径下。
JNI编程指南
技术资料分享FAT32文件系统详解很好的技术资料.zip
个人日常总结,待整理 杂乱的笔记