UML Association Vs. Aggregation Vs. Composition [EXAMPLE]

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?