0% found this document useful (0 votes)
151 views31 pages

UML Diagram

UML DIagram

Uploaded by

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

UML Diagram

UML DIagram

Uploaded by

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

CSE 411

UML Diagrams

Slide Reference: Marty Stepp, 2007.


1
WHAT IS UML AND WHY WE USE UML?

 UML → “Unified Modeling Language”


 Language: express idea, not a methodology

 Modeling: Describing a software system at a high level of


abstraction

 Unified: UML has become a world standard


Object Management Group (OMG): www.omg.org
WHAT IS UML AND WHY WE USE UML?
 It is a industry-standard graphical language for specifying,
visualizing, constructing, and documenting the artifacts of
software systems

 The UML uses mostly graphical notations to express the OO


analysis and design of software projects.

 Simplifies the complex process of software design


 as a sketch: to communicate aspects of system
 forward design: doing UML before coding
 backward design: doing UML after coding as
documentation

 as a blueprint: a complete design to be implemented


 sometimes done with CASE (Computer-Aided Software
Engineering) tools

 as a programming language: with the right tools,


code can be auto-generated and executed from UML

4
WHAT IS UML AND WHY WE USE UML?

Year Version
2003: UML 2.0
2001: UML 1.4
1999: UML 1.3
1997: UML 1.0, 1.1
1996: UML 0.9 & 0.91
1995: Unified Method 0.8

Booch ‘93 OMT - 2


Other methods

Booch ‘91
OMT - 1
UML © Wolfgang Pelz 2000-04

UML SUPPORTED DIAGRAMS

 class  interaction
 package  communication
 sequence
 deployment
 collaboration
 use case  timing
 activity
 state/statechart
UML © Wolfgang Pelz 2000-04

BRIEF OVERVIEW
 class - set of classes, interfaces, collaboration,
relationships

 use case - description of functionality provided


by system along with actors and their connection
to the use case

 interaction - set of objects and their relationships


including messages
UML © Wolfgang Pelz 2000-04

OVERVIEW (CONT.)

 state/statechart - a state machine showing states,


transitions, events, and activities

 activity - statechart sequential flow of activities

 component - physical structure of code in terms


of code components
UML © Wolfgang Pelz 2000-04

ORGANIZATION OF DIAGRAMS

domain expert system designer


 use case  class

 activity  component

 interaction  deployment

 state

 package
UML © Wolfgang Pelz 2000-04

ANOTHER ORGANIZATION

static dynamic
 class  use case

 component  interaction

 package  state

 deployment  activity
UML © Wolfgang Pelz 2000-04

ANOTHER ORGANIZATION
USE-CASE DIAGRAMS
 A use-case diagram is a set of use cases
 A use case is a model of the interaction between
 External users of a software product (actors) and
 The software product itself
 More precisely, an actor is a user playing a specific role

 describing a set of user scenarios


 capturing user requirements
 contract between end user and software developers
USE-CASE DIAGRAMS

Boundary Use Case


Actor Library System

Borrow Employee
Client
Order Title

Fine Remittance

Supervisor
USE-CASE DIAGRAMS
 Actors: A role that a user plays with respect to the system,
including human users and other systems. e.g., inanimate
physical objects (e.g. robot); an external system that needs
some information from the current system.

 Use case: A set of scenarios that describing an interaction


between a user and a system, including alternatives.

 System boundary: rectangle diagram representing the


boundary between the actors and the system.
USE-CASE DIAGRAMS
Association:
communication between an actor and a use case;
Represented by a solid line.

 Generalization: relationship between one general use case


and a special use case (used for defining special
alternatives) Represented by a line with a triangular arrow
head toward the parent use case.
USE-CASE DIAGRAMS
Include: a dotted line labeled <<include>> beginning at base use
case and ending with an arrows pointing to the include use case.
The include relationship occurs when a chunk of behavior is
similar across more than one use case. Use “include” in stead of
copying the description of that behavior.
<<include>>

Extend: a dotted line labeled <<extend>> with an arrow toward the


base case. The extending use case may add behavior to the base
use case. The base class declares “extension points”.
<<extend>>
USE-CASE DIAGRAMS

Figure 16.12
The McGraw-Hill Companies, 2005
USE-CASE DIAGRAMS
 Both Make Appointment
and Request Medication
include Check Patient
Record as a subtask
(include)

 The extension point is


written inside the base case
Pay bill; the extending class
Defer payment adds the
behavior of this extension
point. (extend)

 Pay Bill is a parent use


case and Bill Insurance is
the child use case.
(generalization)
(TogetherSoft, Inc)
HOW DO WE DESIGN CLASSES?
 class identification from project spec /
requirements
 nouns are potential classes, objects, fields
 verbs are potential methods or responsibilities of a
class
 Design the classes.

19
UML CLASS DIAGRAMS
 UML class diagram: a picture of the classes
in an Object Oriented system, their fields
and methods, and connections between the
classes that interact or inherit from each
other

20
DIAGRAM OF ONE CLASS
 class name in top of box
 write <<interface>> on top of interfaces' names
 use italics for an abstract class name

 attributes (optional)
 should include all fields of the object

 operations / methods (optional)


 may omit trivial (get/set) methods
 should not include inherited methods

21
CLASS ATTRIBUTES
 attributes (fields, instance variables)
visibility name : type [count] = default_value

 visibility: + public
# protected
- private
/ derived
 underline static attributes

 derived attribute: not stored, but can


be computed from other attribute values

 attribute example:
- balance : double = 0.00
22
CLASS OPERATIONS / METHODS
 operations / methods
visibility name (parameters) : return_type

 visibility: + public
# protected
- private

 underline static methods


 parameter types listed as (name: type)
 omit return_type on constructors and
when return type is void

 method example:
+ distance(p1: Point, p2: Point): double
23
RELATIONSHIPS BTWN. CLASSES

 generalization: an inheritance relationship


 inheritance between classes
 interface implementation

 association: a usage relationship


 dependency

 aggregation

 composition

24
GENERALIZATION RELATIONSHIPS
 hierarchies drawn top-down with arrows
pointing upward to parent

 line/arrow styles differ, based on whether


parent is a(n):
 class:
solid line, black arrow
 abstract class:
solid line, white arrow
 interface:
dashed line, white arrow
25
ASSOCIATIONAL RELATIONSHIPS
1. multiplicity (how many are used)
*  0, 1, or more
1  1 exactly
 2..4  between 2 and 4, inclusive
 3..*  3 or more
2. name (what relationship the objects have)
3. navigability (direction)

26
MULTIPLICITY OF ASSOCIATIONS
 one-to-one
 each student must carry exactly one ID card

 one-to-many
 one rectangle list can contain many rectangles

27
Car

ASSOCIATION TYPES 1
aggregation
 aggregation: "is part of" 1
Engine
 symbolized by a clear white diamond

Book
 composition: "is entirely made of"
composition
 stronger version of aggregation
1
 the parts live and die with the whole
*
 symbolized by a black diamond
Page

 dependency: "uses temporarily"


 symbolized by dotted line dependency
 often is an implementation
detail, not an intrinsic part of Lottery Random
that object's state Ticket
28
CLASS DIAGRAM EXAMPLE 1
Multiplicity

Customer
1 Simple
Class Aggregation

Rental Invoice
Class

Rental Item 1..*


1 0..1

Composition Simple
Generalization
Association

Checkout Screen
DVD Movie VHS Movie Video Game

29
CLASS DIAGRAM EXAMPLE 2

StudentBody Student
1 100
- firstName : String
+ main (args : String[]) - lastName : String
- homeAddress : Address
- schoolAddress : Address

+ toString() : String
Address
- streetAddress : String
- city : String
- state : String
- zipCode : long

+ toString() : String

30
Thank You!!

You might also like