1Unified Modeling Language (UML)Nelson Padua-PerezChau-Wen TsengDepartment of Computer ScienceUniversity of Maryland, College ParkOverviewUnified Modeling Language (UML)Models & viewsClass diagramsSequence diagrams2UMLUML (Unified Modeling Language)Graphic modeling language for describing object-oriented softwareStarted in 1994Combined notations from 3 leading OO methodsOMT (James Rumbaugh)OOSE (Ivar Jacobson)Booch (Grady Booch)UML MotivationSoftware growing larger & complexDifficult to analyzeNeed to describe software designClearlyConciselyCorrectlyUML equivalent to software “blueprint”Provides simple yet clear abstraction for softwareComputer-aided software engineering (CASE)Tools for generating & analyzing UML3DefinitionsModelAbstraction describing (all or part of) system ViewDepicts selected aspects of a model using set of diagramsDiagramActual depiction of aspect of modelNotationSet of graphical / textual rules for representing viewModels & ViewsSystemModel 1Model 2View 1View 3View 24UMLIndustry standard Many featuresLarge collection of notationsMultiple viewsMultiple diagramsWe focus mainly onLogical view of relationship between classesUML ViewsUse-CaseShow external user (actor) view of system LogicalShow how functionality is implementedComponentShow organization of code componentsDeploymentShow assignment of code to physical computers5(Some) UML DiagramsClassDescribe static structure of the classes in system SequenceDescribe dynamic behavior between users and objects Use caseDescribe functional behavior seen by (external) userStateDescribe dynamic behavior of objects as finite state machineActivityModel dynamic behavior of a system as a flowchartUML ConventionsRectangles ⇒ classes or instancesOvals ⇒ functions or use casesTypes ⇒ preceded by colon, not underlined:SimpleWatchInstances ⇒ underlined namesmyWatch:SimpleWatchDiagrams ⇒ graphsNodes ⇒ entitiesArcs ⇒ relationships between entities6Class DiagramsBatteryload()12Timenow()PushButtonstatepush()release()111112blinkIdxblinkSeconds()blinkMinutes()blinkHours()stopBlinking()referesh()LCDDisplaySimpleWatchClassAssociationMultiplicityAttributesOperationsClass diagrams represent structure of systemSequence DiagramObjectMessageActivationSequence diagrams represent behavior as interactionsblinkHours()blinkMinutes()incrementMinutes()refresh()commitNewTime()stopBlinking()pressButton1()pressButton2()pressButtons1And2()pressButton1():WatchUser:Time:LCDDisplay:SimpleWatch7Use Case DiagramsWatchUser WatchRepairPersonReadTimeSetTimeChangeBatteryActorUse casePackageSimpleWatchUse case diagrams represent functionality of system from external user’s point of viewbutton1&2Pressedbutton1&2Pressedbutton1Pressedbutton2Pressedbutton2Pressedbutton2Pressedbutton1Pressedbutton1&2PressedIncrementMinutesIncrementHoursBlinkHoursBlinkSecondsBlinkMinutesIncrementSecondsStopBlinkingState DiagramsStateInitial stateFinal stateTransitionEvent8UML Sequence DiagramsRepresent behavior in terms of interactions During requirements analysisUsed to refine use case descriptionsDuring system design Used to refine subsystem interfacesSequence Diagram NotationColumns ⇒ ClassesArrows ⇒ MessagesNarrow rectangles ⇒ Activations9Sequence Diagram ExampleSequence of events for printer queueUML Class DiagramsRepresent the (static) structure of the systemDuring analysis Used to model problem domain conceptsDuring detailed design Used to model classes10Class DiagramsClass containsNameStateBehaviorClass DiagramsTypes may be includedOnly class name is required11Sequence Diagram ObservationsRepresents behavior in terms of interactionsComplement the class diagrams which represent structureUseful for finding participating objectsUML Class Diagrams ↔ Java CodeDifferent representation of same informationName, state, behavior of classRelationship(s) between classesShould be able to derive one from the other MotivationUML ⇒ JavaImplement code based on design written in UMLJava ⇒ UMLCreate UML to document design of existing code12Java → UML : Clock ExampleJavaclass Clock // name{// stateint seconds;int minutes;int hours;// behaviorvoid start();void adjustTime();void reset();}Java CodeClass DiagramJava → UML : Printing SystemJavaclass Job {}class Registry {PrintQueue findQueue();}13Java → UML : Printing SystemJavaclass PrintQueue {List printJobs;Printer myPrinter;Registry myRegistry;void newJob();int length();Resources getResource();}Java → UML : Printing SystemJavaclass Printer {Resources myResources;Job curJob;void print();boolean busy();boolean on();}14UML → Java : Printing SystemJavaclass Printer {Resources myResources;Job curJob;void print();boolean busy();boolean on();}UMLSummaryOverview of UMLFocus on class diagramsHow they represent structure of softwareConversion to/from JavaNext lecture will examineHow UML represents relationships between classesMore UML ↔ Java
View Full Document