UML Class Diagram - Javatpoint
文章推薦指數: 80 %
The class diagram depicts a static view of an application. It represents the types of objects residing in the system and the relationships between them. ⇧SCROLLTOTOP Home Java UML Pandas Python Java SQL Android Cloud JavaScript Servlet JSP Struts2 Spring Quiz Projects InterviewQ Comment Forum Training UMLTutorial UMLTutorial UMLBuildingBlocks UMLArchitecture UMLDiagrams UMLRelationship AssociationvsAggregationvsComposition UMLAssociation UMLDependency UMLGeneralization UMLRealization UMLClassDiagram UMLObjectDiagram UMLComponentDiagram UMLDeploymentDiagram UMLInteractionDiagram UMLUseCaseDiagram UMLSequenceDiagram UMLCollaborationDiagram UMLStateMachineDiagram UMLActivityDiagram UMLTimingDiagram UMLTools next→ ←prev UMLClassDiagram Theclassdiagramdepictsastaticviewofanapplication.Itrepresentsthetypesofobjectsresidinginthesystemandtherelationshipsbetweenthem.Aclassconsistsofitsobjects,andalsoitmayinheritfromotherclasses.Aclassdiagramisusedtovisualize,describe,documentvariousdifferentaspectsofthesystem,andalsoconstructexecutablesoftwarecode. Itshowstheattributes,classes,functions,andrelationshipstogiveanoverviewofthesoftwaresystem.Itconstitutesclassnames,attributes,andfunctionsinaseparatecompartmentthathelpsinsoftwaredevelopment.Sinceitisacollectionofclasses,interfaces,associations,collaborations,andconstraints,itistermedasastructuraldiagram. PurposeofClassDiagrams Themainpurposeofclassdiagramsistobuildastaticviewofanapplication.Itistheonlydiagramthatiswidelyusedforconstruction,anditcanbemappedwithobject-orientedlanguages.ItisoneofthemostpopularUMLdiagrams.Followingarethepurposeofclassdiagramsgivenbelow: Itanalysesanddesignsastaticviewofanapplication. Itdescribesthemajorresponsibilitiesofasystem. Itisabaseforcomponentanddeploymentdiagrams. Itincorporatesforwardandreverseengineering. BenefitsofClassDiagrams Itcanrepresenttheobjectmodelforcomplexsystems. Itreducesthemaintenancetimebyprovidinganoverviewofhowanapplicationisstructuredbeforecoding. Itprovidesageneralschematicofanapplicationforbetterunderstanding. Itrepresentsadetailedchartbyhighlightingthedesiredcode,whichistobeprogrammed. Itishelpfulforthestakeholdersandthedevelopers. VitalcomponentsofaClassDiagram Theclassdiagramismadeupofthreesections: UpperSection:Theuppersectionencompassesthenameoftheclass.Aclassisarepresentationofsimilarobjectsthatsharesthesamerelationships,attributes,operations,andsemantics.Someofthefollowingrulesthatshouldbetakenintoaccountwhilerepresentingaclassaregivenbelow: Capitalizetheinitialletteroftheclassname. Placetheclassnameinthecenteroftheuppersection. Aclassnamemustbewritteninboldformat. Thenameoftheabstractclassshouldbewritteninitalicsformat. MiddleSection:Themiddlesectionconstitutestheattributes,whichdescribethequalityoftheclass.Theattributeshavethefollowingcharacteristics: Theattributesarewrittenalongwithitsvisibilityfactors,whicharepublic(+),private(-),protected(#),andpackage(~). Theaccessibilityofanattributeclassisillustratedbythevisibilityfactors. Ameaningfulnameshouldbeassignedtotheattribute,whichwillexplainitsusageinsidetheclass. LowerSection:Thelowersectioncontainmethodsoroperations.Themethodsarerepresentedintheformofalist,whereeachmethodiswritteninasingleline.Itdemonstrateshowaclassinteractswithdata. Relationships InUML,relationshipsareofthreetypes: Dependency:Adependencyisasemanticrelationshipbetweentwoormoreclasseswhereachangeinoneclasscausechangesinanotherclass.Itformsaweakerrelationship. Inthefollowingexample,Student_NameisdependentontheStudent_Id. Generalization:Ageneralizationisarelationshipbetweenaparentclass(superclass)andachildclass(subclass).Inthis,thechildclassisinheritedfromtheparentclass. Forexample,TheCurrentAccount,SavingAccount,andCreditAccountarethegeneralizedformofBankAccount. Association:Itdescribesastaticorphysicalconnectionbetweentwoormoreobjects.Itdepictshowmanyobjectsarethereintherelationship. Forexample,adepartmentisassociatedwiththecollege. Multiplicity:Itdefinesaspecificrangeofallowableinstancesofattributes.Incaseifarangeisnotspecified,oneisconsideredasadefaultmultiplicity. Forexample,multiplepatientsareadmittedtoonehospital. Aggregation:Anaggregationisasubsetofassociation,whichrepresentshasarelationship.Itismorespecificthenassociation.Itdefinesapart-wholeorpart-ofrelationship.Inthiskindofrelationship,thechildclasscanexistindependentlyofitsparentclass. Thecompanyencompassesanumberofemployees,andevenifoneemployeeresigns,thecompanystillexists. Composition:Thecompositionisasubsetofaggregation.Itportraysthedependencybetweentheparentanditschild,whichmeansifonepartisdeleted,thentheotherpartalsogetsdiscarded.Itrepresentsawhole-partrelationship. Acontactbookconsistsofmultiplecontacts,andifyoudeletethecontactbook,allthecontactswillbelost. AbstractClasses Intheabstractclass,noobjectscanbeadirectentityoftheabstractclass.Theabstractclasscanneitherbedeclarednorbeinstantiated.Itisusedtofindthefunctionalitiesacrosstheclasses.Thenotationoftheabstractclassissimilartothatofclass;theonlydifferenceisthatthenameoftheclassiswritteninitalics.Sinceitdoesnotinvolveanyimplementationforagivenfunction,itisbesttousetheabstractclasswithmultipleobjects. Letusassumethatwehaveanabstractclassnameddisplacementwithamethoddeclaredinsideit,andthatmethodwillbecalledasadrive().Now,thisabstractclassmethodcanbeimplementedbyanyobject,forexample,car,bike,scooter,cycle,etc. HowtodrawaClassDiagram? Theclassdiagramisusedmostwidelytoconstructsoftwareapplications.Itnotonlyrepresentsastaticviewofthesystembutalsoallthemajoraspectsofanapplication.Acollectionofclassdiagramsasawholerepresentsasystem. Somekeypointsthatareneededtokeepinmindwhiledrawingaclassdiagramaregivenbelow: Todescribeacompleteaspectofthesystem,itissuggestedtogiveameaningfulnametotheclassdiagram. Theobjectsandtheirrelationshipsshouldbeacknowledgedinadvance. Theattributesandmethods(responsibilities)ofeachclassmustbeknown. Aminimumnumberofdesiredpropertiesshouldbespecifiedasmorenumberoftheunwantedpropertywillleadtoacomplexdiagram. Notescanbeusedasandwhenrequiredbythedevelopertodescribetheaspectsofadiagram. Thediagramsshouldberedrawnandreworkedasmanytimestomakeitcorrectbeforeproducingitsfinalversion. ClassDiagramExample Aclassdiagramdescribingthesalesordersystemisgivenbelow. UsageofClassdiagrams Theclassdiagramisusedtorepresentastaticviewofthesystem.Itplaysanessentialroleintheestablishmentofthecomponentanddeploymentdiagrams.Ithelpstoconstructanexecutablecodetoperformforwardandbackwardengineeringforanysystem,orwecansayitismainlyusedforconstruction.Itrepresentsthemappingwithobject-orientedlanguagesthatareC++,Java,etc.Classdiagramscanbeusedforthefollowingpurposes: Todescribethestaticviewofasystem. Toshowthecollaborationamongeveryinstanceinthestaticview. Todescribethefunctionalitiesperformedbythesystem. Toconstructthesoftwareapplicationusingobject-orientedlanguages. NextTopicUMLObjectDiagram ←prev next→ ForVideosJoinOurYoutubeChannel:JoinNow Feedback SendyourFeedbackto[email protected] HelpOthers,PleaseShare LearnLatestTutorials Splunk SPSS Swagger Transact-SQL Tumblr ReactJS Regex ReinforcementLearning RProgramming RxJS ReactNative PythonDesignPatterns PythonPillow PythonTurtle Keras Preparation Aptitude Reasoning VerbalAbility InterviewQuestions CompanyQuestions TrendingTechnologies ArtificialIntelligence AWS Selenium CloudComputing Hadoop ReactJS DataScience Angular7 Blockchain Git MachineLearning DevOps B.Tech/MCA DBMS DataStructures DAA OperatingSystem ComputerNetwork CompilerDesign ComputerOrganization DiscreteMathematics EthicalHacking ComputerGraphics SoftwareEngineering WebTechnology CyberSecurity Automata CProgramming C++ Java .Net Python Programs ControlSystem DataMining DataWarehouse JavatpointServicesJavaTpointofferstoomanyhighqualityservices.Mailuson[email protected],togetmoreinformationaboutgivenservices.WebsiteDesigningWebsiteDevelopmentJavaDevelopmentPHPDevelopmentWordPressGraphicDesigningLogoDigitalMarketingOnPageandOffPageSEOPPCContentDevelopmentCorporateTrainingClassroomandOnlineTrainingDataEntryTrainingForCollegeCampusJavaTpointofferscollegecampustrainingonCoreJava,AdvanceJava,.Net,Android,Hadoop,PHP,WebTechnologyandPython.Pleasemailyourrequirementat[email protected]Duration:1weekto2weekLike/Subscribeusforlatestupdatesornewsletter
延伸文章資訊
- 1UML - Class Diagram - Tutorialspoint
Class diagram describes the attributes and operations of a class and also the constraints imposed...
- 2Day7. UML類別圖說明 - iT 邦幫忙
Class diagram describes the structure of a system by showing the system's classes, their attribut...
- 3The UML 2 class diagram - IBM Developer
In general, these diagrams allow for design validation and design communication between individua...
- 4UML Class Diagram Tutorial - Lucidchart
Class diagrams are one of the most useful types of diagrams in UML as they clearly map out the st...
- 5類別圖- 維基百科,自由的百科全書 - Wikipedia
類別圖是軟體工程的統一建模語言一種靜態結構圖,該圖描述了系統的類別集合,類別的屬性和類別之間的關係。 UML 2.0 Diagrams ...