0% found this document useful (0 votes)
119 views23 pages

Introduction To Unified Modelling Language Uml

The document discusses UML (Unified Modeling Language), which is a standardized design language for object-oriented programming. It can be used to model classes, objects, and interactions in a project. UML diagrams include class diagrams, which show relationships between classes; object diagrams, which show interactions between objects; and sequence diagrams, which show time-based interactions between objects. The document provides examples and explanations of how to represent various modeling elements like classes, interfaces, inheritance, and associations in UML diagrams.

Uploaded by

hughbertz
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)
119 views23 pages

Introduction To Unified Modelling Language Uml

The document discusses UML (Unified Modeling Language), which is a standardized design language for object-oriented programming. It can be used to model classes, objects, and interactions in a project. UML diagrams include class diagrams, which show relationships between classes; object diagrams, which show interactions between objects; and sequence diagrams, which show time-based interactions between objects. The document provides examples and explanations of how to represent various modeling elements like classes, interfaces, inheritance, and associations in UML diagrams.

Uploaded by

hughbertz
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/ 23

UML: Uniform Modeling Language

UML is a standardized design language for object-oriented


programming in various languages. The website for UML is
http://www.uml.org. UML diagrams can be classified into four
types.

Class Diagram. Shows relationships between various classes in


a project.

UML: Uniform Modeling Language


UML is a standardized design language for object-oriented
programming in various languages. The website for UML is
http://www.uml.org. UML diagrams can be classified into four
types.

Class Diagram. Shows relationships between various classes in


a project.

Object Diagram. Shows interactions between various objects


in your project.

UML: Uniform Modeling Language


UML is a standardized design language for object-oriented
programming in various languages. The website for UML is
http://www.uml.org. UML diagrams can be classified into four
types.

Class Diagram. Shows relationships between various classes in


a project.

Object Diagram. Shows interactions between various objects


in your project.

Collaboration Diagram. Shows associations between various


objects. Similar to relationships between classes but differs
since we usually show the methods being called and values
being returned.

UML: Uniform Modeling Language


UML is a standardized design language for object-oriented
programming in various languages. The website for UML is
http://www.uml.org. UML diagrams can be classified into four
types.

Class Diagram. Shows relationships between various classes in


a project.

Object Diagram. Shows interactions between various objects


in your project.

Collaboration Diagram. Shows associations between various


objects. Similar to relationships between classes but differs
since we usually show the methods being called and values
being returned.

Sequence Diagram. Shows interactions between various


objects based on a time-line.

Class Diagrams

Classes are drawn as rectangles, which may be divided into 1,


2 or 3 partitions. The top partition is for the class name, the
second one for the class variables, and the third one for the
methods or operations. Each variable/method is preceded by
a visibility indicator.

+ indicates public
- indicates private
# indicates protected

Class Diagrams

Classes are drawn as rectangles, which may be divided into 1,


2 or 3 partitions. The top partition is for the class name, the
second one for the class variables, and the third one for the
methods or operations. Each variable/method is preceded by
a visibility indicator.

+ indicates public
- indicates private
# indicates protected

Interfaces are shown as classes except it has only two


partitions. A interface name is preceded by a stereotype tag
to show that it is a special kind of a class.

Class Diagrams

Classes are drawn as rectangles, which may be divided into 1,


2 or 3 partitions. The top partition is for the class name, the
second one for the class variables, and the third one for the
methods or operations. Each variable/method is preceded by
a visibility indicator.

+ indicates public
- indicates private
# indicates protected

Interfaces are shown as classes except it has only two


partitions. A interface name is preceded by a stereotype tag
to show that it is a special kind of a class.

Methods/classes that are abstract are shown italicized.

UML Class Diagram


Rectangle
-width: double
-length: double
+Rectangle()
+calculateArea(): double

We are using the Dia program to generate the UML diagrams. It is


available for free for Linux, MS Windows, MacOS X from
http://projects.gnome.org/dia/
For eclipse, you can download the free Object Aid UML reverse
engineering plugin that draws UML diagrams for your existing classes!

UML Interface Diagram

interface

Drawable
+draw()
+fill()

Inheritance and Associations

Inheritance. A solid line with a closed arrowhead from the


subclass to the superclass.

Implements. A dashed line with a closed arrowhead from the


implementing class to the interface.

Inheritance

Inheritance Hierarchy

Animal

Invertebrae

Amphibian

Vertebrae

Reptile

Mammal

Dog

Cat

A Package
java.animals

Animal

Invertebrae

Amphibian

Vertebrae

Mammal

Dog

Reptile

Cat

Implements

Associations

Associations (or dependencies). A solid labeled line shows


that two classes are associated. A small solid triangle (right
next to the label) shows the direction of the association. An
optional open arrowhead can be used to denote the direction
of the association.

Numbers at either end indicate are the multiplicity indicators.


Here are are some examples of multiplicity indicators.
1
one
0..2 zero to two
0.. zero or more

zero or more
1.. one or more

Association Example

Aggregation

An Aggregation is an association in which one class contains


many others. The container class has a diamond on its end of
the association line.

Inheritance and Association

Employees Example
Firm
+main(args:String[]): void
1
1

Staff
-staffList: StaffMember[]
+payday(): void

StaffMember
#name: String
#address: String
#phone: String

0..*

+toString(): String
1
+pay(): double

Volunteer
+pay(): double

Employee
#socialSecurityNumber: String
#payRate: double
+toString(): String
+pay(): double

Executive

Hourly

-bonus: double

-hoursWorked: int

+awardBonus(execBonus:double): void
+pay(): double

+addHours(moreHours:int): void
+pay(): double
+toString(): String

A Clock Heirarchy Diagram


<<interface>>

javax.swing.JApplet

ActionListener
+actionPerformed(event:ActionEvent): void

Clock
#seconds: int
#minutes: int
#hours: int

Uses
1

+getSeconds(): int
+getMinutes(): int
+getHours(): int
+draw(page:Graphics): void
+paint(page:Graphics): void
+actionPerformed(event:ActionEvent): void

actionPerformed(event)
1
The paint method calls
the draw method

javax.swing.Timer
+Timer(delay:int,listener:ActionListener)

DigitalClock
+draw(page:Graphics): void

AnalogClock
+draw(page:Graphics): void

The Address Book Class Diagram


interface

CmdLineAddressBook

Comparable

-mycontacts: AddressBook

+compareTo(obj:Object): int

1
Uses
1

Contact

AddressBook

-name: Name
-address: Address
-phone: String
-email: String
-homePage: String
-birthDate: ContactDate
-lastMeeting: ContactDate
-relationship: String
-photo: Image
-note: String
1

-contacts: Contact[]
-size: int
-capacity: int
-dataFile: String
-DEBUG: boolean = false
-tags: String[]
-nextToken: String
1
Uses

Uses

Uses
Uses

Uses
Uses

Uses

Uses

Uses
Uses
Uses

Name
-first: String
-middle: String
-last: String

Address
-postOfficeBox: String
-streetAddr: String
-city: String
-state: String
-postalCode: String
-country: String

ContactDate
-date: Date
-df: DateFormat

Get

Object Diagrams
Objects are drawn the same way as classes with 1/2/3 partitions.
The difference is that names for objects are underlined and consist
of the name and type of the objects.
When depicting object interactions, an active object is shown in
bold face.
Objects send messages to each other (through method class and
return values). This are shown as labeled links with an arrow
denoting the direction.
[object1:RectangleUser]

calculateArea

[object2:Rectangle]

Object Interaction
app: CmdLineAddressBook
mycontacts:AddressBook
mycontacts: AddressBook
...

contacts: Contact[]
...
create

addContact()
running AddMenu()
sortContacts()

running printMenu()

getAllContacts()
Contact[]

findByName(fname, lname)
running findMenu()
Contact[]

You might also like