0% found this document useful (0 votes)
107 views7 pages

UML Diagrams Presentation

UML (Unified Modeling Language) is a modeling language used to specify, visualize, construct, and document object-oriented software systems. It provides standard visual modeling techniques like class and object diagrams to help describe a software system's design. UML was developed in the 1990s by combining the leading object-oriented design methods at the time. UML diagrams depict different views of a system and can be used to derive code from a design or document an existing system's design.

Uploaded by

Tavo Tavo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views7 pages

UML Diagrams Presentation

UML (Unified Modeling Language) is a modeling language used to specify, visualize, construct, and document object-oriented software systems. It provides standard visual modeling techniques like class and object diagrams to help describe a software system's design. UML was developed in the 1990s by combining the leading object-oriented design methods at the time. UML diagrams depict different views of a system and can be used to derive code from a design or document an existing system's design.

Uploaded by

Tavo Tavo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CMSC 132: UML (Unified Modeling Language)

Object-Oriented Programming II UML is a modeling language for


Specifying
Visualizing
Constructing
Unified Modeling Language Documenting

(UML) object-oriented software

Department of Computer Science


University of Maryland, College Park

Motivation Goals
Software growing larger & complex Provide a software blueprint
Difficult to describe and analyze Simple yet clear abstraction for software

Use UML to help Describe software design


Visualize design of software Clearly
Provide abstract model of software Concisely
Correctly

History of UML UML Diagrams


Started in 1994 UML provides a number of diagrams that
Combines 3 leading OO methods Describe a model of all or part of system
OMT (James Rumbaugh) From a particular point of view
OOSE (Ivar Jacobson) With varying level of abstraction
Booch (Grady Booch) Using certain set of notations

System

Model 1 View 1
View 2
View 3

Model 2

1
Class Diagram Class Diagram
Represents (static) structure of system Class

Multiplicity SimpleWatch Association


A class diagram displays 1 1 1 1
2 1 2 1
Information for class PushButton LCDDisplay Battery Time
state load() now()
Relationships between classes push()
blinkIdx
blinkSeconds()
release() blinkMinutes()
blinkHours()
stopBlinking() Attributes
referesh()

Operations

Class diagrams represent structure of system

Class Diagrams Class Diagram


Information for class contains Class name is required
Name Other information optional
State State, behavior
Behavior Types, visibility

UML Class Diagrams Java Code Java UML : Clock Example


Different representation of same information Java
Name, state, behavior of class class Clock { // name
Relationships between classes // state
Should be able to derive one from the other int seconds;
int minutes;
Motivation
int hours;
UML Java
// behavior
Implement code based on design written in UML
void start();
Java UML
void adjustTime();
Create UML to document design of existing code void reset();
}
Java Code Class Diagram

2
Class Diagram Notation Java UML : Clock Example
UML notation Java Clock
Type type name preceded by colon : class Clock { // name
seconds : int
Visibility prefix symbol // state minutes : int
+ public private int seconds; hours : int
private private int minutes;
private int hours; + setTime( ) : void
Types of relationships
+ adjustTime( ) : void
Generalization // behavior
+ reset( ) : void
Inheritance public void setTime( );
Implementation public void adjustTime(int value);
Association public void reset( );
Dependency }
Java Code Class Diagram

Generalization Generalization Example


Denotes inheritance between classes Inheritance
Can view as is a relationship
Example
Lecturer is a person (Lecturer extends Person class)
Types of generalization
Subclass extends superclass
Solid line ending in (open) triangle
Class implements interface
Dotted line ending in (open) triangle Laptop, Desktop, PDA inherit
state & behavior from Computer

Generalization Example Association


Implementation Denotes interaction between two classes

Example
interface Lecturer teaches course
Laptop
DVDplayer Indicates relationship between Lecturer & Course

Laptop implements DVDplayer interface Lecturer Course

3
Association w/ Navigation Association w/o Navigation
Navigation information Undirected edge
Relationship between classes may be directional Relationship between classes may be bi-directional
Only class A can send messages to class B Direction of relationship may be unknown
Arrowhead indicates direction of relationship Examples
Example
class Course { class Lecturer {
class Course { class Lecturer { Lecturer TheBoss; Course [ ] class;
Lecturer TheBoss; } }
} }

class Foo class Bar

Permanent Association Temporary Association (Dependency)


Permanent / structural association A transitory relationship between classes
Class A contains reference to class B in data field Always directed (class A depends on B)
Can view as has a relationship Indicates change in class B may affect class A
Also referred to as composition Can view as uses a relationship
Example Represented by dotted line with arrowhead
Example
class A { class B {
B x; A B
} }

A has a B A depends on B

Dependency UML Examples


Dependence may be caused by Read UML class diagram
Local variable Try to understand relationships
Parameter Practice converting to / from Java code
Return value Examples
Example Computer disk organization
Banking system
class A { class B { Home heating system
B foo(B x) { Printing system
B y = new( );

}} }

4
UML Example Computer System UML Example Banking System
Try to read & understand UML diagram

CPU is associated with Controllers


DiskDrive is associated with SCSIController
Bank associated with Accounts
SCSIController is a (type of) Controller
Checking, Savings, MoneyMarket are type of Accounts

UML Example Home Heating System UML Example Library System


Try to read & understand UML diagram

Thermostat associated with (has a) Room


Thermostat associated with (has a) Heater Books are associated with (has some) Pages
ElectricHeater is a specialized Heater Patron & Shelf depend on (temporarily use) Books
AubeTH101D is a specialized Thermostat

UML Java : Computer System UML Java : Computer System


UML UML

Java
class Controller {
}
class SCSIController extends Controller { Java
} Design code using all available information in UML

5
UML Java : Computer System Java UML : Printing System
Java Java
class CPU { class Registry {
Controller myCtlrs[ ]; PrintQueue findQueue();
} }
class Controller { class PrintQueue {
CPU myCPU; List printJobs;
} Printer myPrinter;
class SCSIController extends Controller { Registry myRegistry;
DiskDrive myDrive[4]; void newJob();
} int length();
Class DiskDrive { Resources getResource();
SCSIController mySCSI; }
}

Java UML : Printing System Java UML : Printing System


Java Java
Class Printer { All together
Resources myResources;
Job curJob;
void print();
boolean busy();
boolean on();
}
class Job {
Job(Registry r) {

}
}

UML Tools Amateras UML Editor


Can automatically generate Drag-n-drop classes
UML diagrams from code into UML diagram
Code from UML diagrams Auto creates class w/
Examples attributes & methods
AmaterasUML Violet Add links manually
No directed
associations
Use undirected
association + directed
dependency together

6
Amateras UML Editor Eclipse Plugin Violet UML Editor
Drag-n-drop classes
into UML diagram
Auto creates class w/
attributes & methods
Add links manually
No undirected
associations
Use directed
association in both
directions instead

Violet UML Editor Eclipse Plugin UML Summary


UML modeling language
Visually represents design of software system
We focused on class diagrams
Contents of a class
Relationship between classes
You should be able to
Draw UML class diagram given Java code
Write Java code given UML class diagram

You might also like