UML Association Vs. Aggregation Vs. Composition [EXAMPLE]
文章推薦指數: 80 %
An aggregation is a subtype of an association relationship in UML. Aggregation and composition are both the types of association relationship in ... Skiptocontent RelationshipsinUMLdiagramareusedtorepresentaconnectionbetweenvariousthings.Arelationshipisaconnectionamongstthingssuchasstructural,behavioral,orgroupingthingsintheunifiedmodelinglanguage. FollowingarethedifferenttypesofstandardrelationshipsinUML, Association Dependency Generalization Realization Otherthanthese,UMLallowstheuseofaggregationandacompositionrelationship. InthisUMLtutorial,youwilllearn: UMLAssociation UMLComposition UMLAggregation Difference UMLAssociation Itisastructuralrelationshipthatrepresentsobjectscanbeconnectedorassociatedwithanotherobjectinsidethesystem.FollowingconstraintscanbeappliedtotheUMLAssociationrelationship. {implicit}–Implicitconstraintsspecifythattherelationshipisnotmanifest;itisbaseduponaconcept. {ordered}–Orderedconstraintsspecifythatthesetofobjectsatoneendofanassociationareinaspecificway. {changeable}–Changeableconstraintspecifiesthattheconnectionbetweenvariousobjectsinthesystemcanbeadded,removed,andmodifiedaspertherequirement. {addOnly}–Itspecifiesthatthenewconnectionscanbeaddedfromanobjectwhichissituatedattheotherendanassociation. {frozen}–Itspecifiesthatwhenalinkisinsertedbetweentwoobjects,thenitcannotbemodifiedwhilethefrozenconstraintisactiveonthegivenlinkoraconnection. WecanalsocreateaclassthathasUMLAssociationproperties;itiscalledasanassociationclass. ReflexiveAssociation ThereflexiveassociationisasubtypeofassociationrelationshipinUML.Inareflexiveassociation,theinstancesofthesameclasscanberelatedtoeachother.Aninstanceofaclassisalsosaidtobeanobject. Reflexiveassociationstatesthatalinkoraconnectioncanbepresentwithintheobjectsofthesameclass. Example: Letusconsideranexampleofaclassfruit. Thefruitclasshastwoinstances,suchasmangoandapple.Reflexiveassociationstatesthatalinkbetweenmangoandapplecanbepresentastheyareinstancesofthesameclass,suchasfruit. ReflexiveAssociation DirectedAssociation Asthenamesuggests,thedirectedassociationisrelatedtothedirectionofflowwithinassociationclasses. Inadirectedassociation,theflowisdirected.Theassociationfromoneclasstoanotherclassflowsinasingledirectiononly. Itisdenotedusingasolidlinewithanarrowhead. UMLAssociationExample: Youcansaythatthereisadirectedassociationrelationshipbetweenaserverandaclient. Aservercanprocesstherequestsofaclient.Thisflowisunidirectional,thatflowsfromservertoclientonly.Henceadirectedassociationrelationshipcanbepresentwithinserversandclientsofasystem. DirectedAssociation UMLComposition ItisnotastandardUMLRelationship,butitisstillusedinvariousapplications. Compositeaggregationisasubtypeofaggregationrelationwithcharacteristicsas: Itisatwo-wayassociationbetweentheobjects. Itisawhole/partrelationship. Ifacompositeisdeleted,allotherpartsassociatedwithitaredeleted. Compositeaggregationisdescribedasabinaryassociationdecoratedwithafilledblackdiamondattheaggregate(whole)end. Thefoldercouldcontainmanyfiles,whileeachFilehasexactlyoneFolderparent.Ifafolderisdeleted,allcontainedfilesareremovedaswell. Inacompositeaggregation,anobjectmaybeapartofonlyonecompositeatatime. UMLCompositionExample: Forexample,inawindowingsystem,aFramebelongstopreciselyoneWindow.Inacompositeaggregation,thewholesystemisresponsibleforthedispositionofitsparts,whichmeansthatthecompositemustmanagethecreationanddestructionofitsparts. Composition UMLAggregation AnaggregationisasubtypeofanassociationrelationshipinUML.AggregationandcompositionareboththetypesofassociationrelationshipinUML.Anaggregationrelationshipcanbedescribedinsimplewordsas“anobjectofoneclasscanownoraccesstheobjectsofanotherclass.” Inanaggregationrelationship,thedependentobjectremainsinthescopeofarelationshipevenwhenthesourceobjectisdestroyed. UMLAggregationExample: Letusconsideranexampleofacarandawheel. Acarneedsawheeltofunctioncorrectly,butawheeldoesn’talwaysneedacar.Itcanalsobeusedwiththebike,bicycle,oranyothervehiclesbutnotaparticularcar.Here,thewheelobjectismeaningfulevenwithoutthecarobject.SuchtypeofrelationshipiscalledUMLAggregationrelation. Aggregation AssociationVs.AggregationVs.Composition Association Aggregation Composition Associationrelationshipisdenotedusinganarrow. Aggregationrelationshipisdenotedusingastraightlinewithanemptyarrowheadatoneend. Compositionrelationshipisdenotedusingastraightlinewithafilledarrowheadatanyoneoftheends. AssociationcanexistbetweentwoormoreclassesinUML. Aggregationisapartofanassociationrelationship. Thecompositionisapartofanassociationrelationship. Therecanbeone-one,one-many,many-one,andmany-manyassociationpresentbetweentheassociationclasses. Aggregationisconsideredasaweaktypeofassociation. Thecompositionisconsideredasastrongtypeofassociation. Inanassociationrelationship,oneormoreobjectscanbeassociatedwitheachother. Inanaggregationrelationship,objectsthatareassociatedwitheachothercanremaininthescopeofasystemwithouteachother. Inacompositionrelationship,objectsthatareassociatedwitheachothercannotremaininthescopewithouteachother. Objectsarelinkedwitheachother. Linkedobjectsarenotdependentupontheotherobject. Objectsarehighlydependentuponeachother. InUMLAssociation,deletingoneelementmayormaynotaffectanotherassociatedelement. InUMLAggregation,deletingoneelementdoesnotaffectanotherassociatedelement. InUMLComposition,deletingoneelementaffectsanotherassociatedelement. Example: Ateacherisassociatedwithmultiplestudents. Or ateacherprovidesinstructionstothestudents. Example: Acarneedsawheel,butitdoesn’talwaysrequirethesamewheel.Acarcanfunctionadequatelywithanotherwheelaswell. Example: Afileisplacedinsidethefolder.Ifonedeletesthefolder,thenthefileassociatedwiththatgivenfolderisalsodeleted. Summary Arelationshipisaconnectionbetweenthings. Association,dependency,generalization,andrealizationarevariousrelationshipsprovidedbyUML. Apartfromstandardrelationships,compositionandaggregationareusedinsidetheUML. AggregationandcompositionareboththetypesofassociationrelationshipinUML. TheUMLCompositionisatwo-wayrelationshipwhichisalsocalledasabinaryrelationship. CheckourarticleonBestUMLTools:-ClickHere YouMightLike: UMLDiagrams:History,Types,Characteristics,Versions,Tools WhatisObjectDiagraminUML?LearnwithExample UMLTutorial–LearnUnifiedModellingLanguageDiagram WhatisUMLComponentDiagraminOOAD?Notations,Example 21BestFREEMicrosoftVisioAlternatives&Competitors(2022) Postnavigation ReportaBug Previous PrevNextContinue Scrolltotop ToggleMenuClose Searchfor: Search
延伸文章資訊
- 1UML類別圖:Aggregation vs. Composition - 自學程式誌
Aggregation. 圖三. Aggregation範例。左邊:類別圖右邊:原始碼 ...
- 2【UML】Class Diagram 類別圖(下):Relationships 關係
Relationships 關係. Instance-level 物件層級. Dependency 依賴; Association 關聯; Aggregation 聚合; Composition...
- 3UML Association vs Aggregation vs Composition | EdrawMax
Aggregations Represented in a UML Diagram ... Aggregation is an association in which the entities...
- 4UML Composition
UML composite aggregation (composition) relationship means that at most one composite object has ...
- 5UML Association vs Aggregation vs Composition
Aggregation implies a relationship where the child can exist independently of the parent. Example...