DOC PREVIEW
UMD CMSC 132 - Unified Modeling Language (UML)

This preview shows page 1-2-3-19-20-38-39-40 out of 40 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC 132: Object-Oriented Programming IIUnified Modeling Language (UML)Department of Computer ScienceUniversity of Maryland, College ParkUML (Unified Modeling Language)UML is a modeling language forSpecifyingVisualizingConstructingDocumenting object-oriented softwareMotivationSoftware growing larger & complexDifficult to describe and analyzeUse UML to help Visualize design of softwareProvide abstract model of softwareGoalsProvide a software “blueprint”Simple yet clear abstraction for softwareDescribe software designClearlyConciselyCorrectlyHistory of UMLStarted in 1994Combines 3 leading OO methodsOMT (James Rumbaugh)OOSE (Ivar Jacobson)Booch (Grady Booch)UML Diagrams UML provides a number of diagrams thatDescribe a model of all or part of systemFrom a particular point of viewWith varying level of abstraction Using certain set of notationsSystemModel 1Model 2View 1View 3View 2Class DiagramRepresents (static) structure of systemA class diagram displaysInformation for classRelationships between classesClass DiagramBatteryload()12Timenow()PushButtonstatepush()release()111112blinkIdxblinkSeconds()blinkMinutes()blinkHours()stopBlinking()referesh()LCDDisplaySimpleWatchClassAssociationMultiplicityAttributesOperationsClass diagrams represent structure of systemClass DiagramsInformation for class containsNameStateBehaviorClass DiagramClass name is requiredOther information optionalState, behaviorTypes, visibility…UML Class Diagrams  Java CodeDifferent representation of same informationName, state, behavior of classRelationships 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 codeJava  UML : Clock ExampleJavaclass Clock { // name// stateint seconds;int minutes;int hours;// behaviorvoid start();void adjustTime();void reset();}Java CodeClass DiagramClass Diagram NotationUML notationType  type name preceded by colon :Visibility  prefix symbol+ public – privateTypes of relationshipsGeneralizationInheritanceImplementationAssociationDependencyJava  UML : Clock ExampleJavaclass Clock { // name// stateprivate int seconds;private int minutes;private int hours;// behaviorpublic void setTime( );public void adjustTime(int value);public void reset( );} Java Code Class DiagramClock– seconds : int– minutes : int– hours : int+ setTime( ) : void+ adjustTime( ) : void+ reset( ) : voidGeneralizationDenotes inheritance between classesCan view as “is a” relationshipExampleLecturer is a person (Lecturer extends Person class)Types of generalizationSubclass extends superclassSolid line ending in (open) triangleClass implements interfaceDotted line ending in (open) triangleGeneralization ExampleLaptop, Desktop, PDA inherit state & behavior from Computer InheritanceGeneralization ExampleImplementationLaptop implements DVDplayer interfaceLaptop«interface» DVDplayerAssociationDenotes interaction between two classesExampleLecturer teaches courseIndicates relationship between Lecturer & CourseLecturer CourseAssociation w/ NavigationNavigation informationRelationship between classes may be directionalOnly class A can send messages to class BArrowhead indicates direction of relationshipExampleclass Course { class Lecturer {Lecturer TheBoss; …} }Association w/o NavigationUndirected edgeRelationship between classes may be bi-directionalDirection of relationship may be unknownExamplesclass Course { class Lecturer {Lecturer TheBoss; Course [ ] class;} }class Foo class BarPermanent AssociationPermanent / structural associationClass A contains reference to class B in data fieldCan view as “has a” relationshipAlso referred to as compositionExampleclass A { class B {B x; …} }A has a BTemporary Association (Dependency)A transitory relationship between classesAlways directed (class A depends on B)Indicates change in class B may affect class ACan view as “uses a” relationshipRepresented by dotted line with arrowheadExampleA depends on B A BDependencyDependence may be caused byLocal variableParameterReturn valueExampleclass A { class B {B foo(B x) { …B y = new( ); …… …}} }UML ExamplesRead UML class diagramTry to understand relationshipsPractice converting to / from Java codeExamplesComputer disk organizationBanking systemHome heating systemPrinting systemUML Example – Computer SystemTry to read & understand UML diagram• CPU is associated with Controllers• DiskDrive is associated with SCSIController• SCSIController is a (type of) ControllerUML Example – Banking System• Bank associated with Accounts• Checking, Savings, MoneyMarket are type of AccountsUML Example – Home Heating System• Thermostat associated with (has a) Room • Thermostat associated with (has a) Heater• ElectricHeater is a specialized Heater• AubeTH101D is a specialized ThermostatUML Example – Library SystemTry to read & understand UML diagram• Books are associated with (has some) Pages• Patron & Shelf depend on (temporarily use) BooksUML  Java : Computer SystemUMLJavaclass Controller {}class SCSIController extends Controller {}UML  Java : Computer SystemUMLJavaDesign code using all available information in UML…UML  Java : Computer SystemJavaclass CPU {Controller myCtlrs[ ];}class Controller {CPU myCPU;}class SCSIController extends Controller {DiskDrive myDrive[4];}Class DiskDrive {SCSIController mySCSI;}Java  UML : Printing SystemJavaclass Registry {PrintQueue findQueue();}class 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();}class Job {Job(Registry r) {…}}Java  UML : Printing SystemJava All togetherUML ToolsCan automatically generateUML diagrams from codeCode from UML diagramsExamplesAmaterasUMLVioletAmateras UML EditorDrag-n-drop classes into UML diagramAuto creates class w/ attributes & methodsAdd links manuallyNo directed associationsUse undirected association + directed dependency togetherAmateras UML Editor – Eclipse PluginViolet UML EditorDrag-n-drop classes into UML diagramAuto creates class w/ attributes & methodsAdd links manuallyNo undirected associationsUse directed association in bothdirections insteadViolet UML Editor – Eclipse PluginUML SummaryUML  modeling languageVisually represents design of software systemWe focused on


View Full Document

UMD CMSC 132 - Unified Modeling Language (UML)

Documents in this Course
Notes

Notes

8 pages

Recursion

Recursion

12 pages

Sorting

Sorting

31 pages

HTML

HTML

7 pages

Trees

Trees

19 pages

HTML

HTML

18 pages

Trees

Trees

19 pages

Honors

Honors

19 pages

Lecture 1

Lecture 1

11 pages

Quiz #3

Quiz #3

2 pages

Hashing

Hashing

21 pages

Load more
Download Unified Modeling Language (UML)
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Unified Modeling Language (UML) and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Unified Modeling Language (UML) 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?