Top Banner
Chapter Two Chapter Two The UML – The UML – Unified Modeling Unified Modeling Language Language Ku-Yaw Chang Ku-Yaw Chang [email protected] [email protected] Assistant Professor, Department of Assistant Professor, Department of Computer Science and Information Engineering Computer Science and Information Engineering Da-Yeh University Da-Yeh University
25

Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang [email protected] Assistant Professor, Department of Computer Science and Information.

Jan 03, 2016

Download

Documents

Sophia Foster
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

Chapter TwoChapter Two

The UML –The UML –Unified Modeling LanguageUnified Modeling Language

Ku-Yaw ChangKu-Yaw [email protected]@mail.dyu.edu.tw

Assistant Professor, Department of Assistant Professor, Department of Computer Science and Information EngineeringComputer Science and Information Engineering

Da-Yeh UniversityDa-Yeh University

Page 2: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

22Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

OutlineOutline

OverviewOverview

What is the UML?What is the UML?

Why use the UML?Why use the UML?

The class diagramThe class diagram

Interaction DiagramsInteraction Diagrams

SummarySummary

Page 3: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

33Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

OverviewOverview

A brief overview of the Unified Modeling A brief overview of the Unified Modeling Language (UML)Language (UML) What the UML is and why to use itWhat the UML is and why to use it Essential UML diagramsEssential UML diagrams

The The Class DiagramClass Diagram

The The Interaction DiagramInteraction Diagram

Page 4: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

44Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

OutlineOutline

OverviewOverview

What is the UML?What is the UML?

Why use the UML?Why use the UML?

The class diagramThe class diagram

Interaction DiagramsInteraction Diagrams

SummarySummary

Page 5: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

55Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

What is the UML?What is the UML?

A visual language to create models of A visual language to create models of programsprograms A drawing notation with semanticsA drawing notation with semantics A diagrammatic representation of the A diagrammatic representation of the

programsprograms

Different diagrams forDifferent diagrams for AnalysisAnalysis DesignDesign Implementation (dissemination)Implementation (dissemination)

Page 6: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

66Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

UML DiagramsUML Diagrams

In the analysis phaseIn the analysis phase Use Case DiagramsUse Case Diagrams

Entities interacting with the systemEntities interacting with the systemFunction pointsFunction points

Activity DiagramsActivity DiagramsWorkflow of the problem domainWorkflow of the problem domain

Looking at object interactionsLooking at object interactions Interaction DiagramsInteraction Diagrams

How specific objects interact with each otherHow specific objects interact with each otherSequence DiagramSequence Diagram is the most popular is the most popular

Page 7: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

77Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

UML DiagramsUML Diagrams

In the design phaseIn the design phase Class DiagramsClass Diagrams

Detail the relationships between the classesDetail the relationships between the classes

Looking at an object’s behaviorsLooking at an object’s behaviors State DiagramsState Diagrams

Detail the different states an object may be inDetail the different states an object may be in

The transitions between these statesThe transitions between these states

In the deployment phaseIn the deployment phase DeploymentDeployment Diagrams Diagrams

How different modules will be deployedHow different modules will be deployed

Page 8: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

88Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

OutlineOutline

OverviewOverview

What is the UML?What is the UML?

Why use the UML?Why use the UML?

The class diagramThe class diagram

Interaction DiagramsInteraction Diagrams

SummarySummary

Page 9: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

99Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Why Use the UML?Why Use the UML?

For communicationFor communication With yourself, team members and customersWith yourself, team members and customers

For clarityFor clarity To determine if my understanding of the system is the To determine if my understanding of the system is the

same as otherssame as others

For precisionFor precision A better way of describing object-oriented designsA better way of describing object-oriented designs Force the designer to think through his/her approachForce the designer to think through his/her approach

Page 10: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1010Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

OutlineOutline

OverviewOverview

What is the UML?What is the UML?

Why use the UML?Why use the UML?

The class diagramThe class diagram

Interaction DiagramsInteraction Diagrams

SummarySummary

Page 11: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1111Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

The Class DiagramThe Class Diagram

The most basic of UML diagramThe most basic of UML diagram Describe classesDescribe classes Show the relationships between themShow the relationships between them

When one class is a “kind of” another classWhen one class is a “kind of” another class is-ais-a relationship relationship

When there are associations between two classesWhen there are associations between two classes One class “contains” another class: the One class “contains” another class: the has-ahas-a relationship relationship

CompositionComposition: the contained item is a part of the containing : the contained item is a part of the containing itemitem

AggregationAggregation: a collection of things that can exist on their : a collection of things that can exist on their ownown

One class “uses” another classOne class “uses” another class

Page 12: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1212Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Class InformationClass Information

Each rectangle represents a classEach rectangle represents a class The The namename of the class of the class The The data membersdata members of the class of the class The The methods (functions)methods (functions) of the class of the class

Notation for accessNotation for access PublicPublic

Notated with a plus sign (+)Notated with a plus sign (+) ProtectedProtected

Notated with a pound sign (#)Notated with a pound sign (#) PrivatePrivate

Notated with a minus sign (-)Notated with a minus sign (-)

Page 13: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1313Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Class Diagram – Class Diagram – Its Three VariationsIts Three Variations

SquareSquare

+display()

Square

-length : double

+display()

Whenever we refer to a class name, we will bold it as Whenever we refer to a class name, we will bold it as done here.done here.

Page 14: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1414Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Class Diagram – Class Diagram – is-ais-a relationship relationship

Shape is Shape is italicizeditalicized – meaning it is an abstract – meaning it is an abstract classclass

Shape

Line SquarePoint

Page 15: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1515Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Class Diagram – Class Diagram – has-ahas-a relationship relationship

Aggregation ( an unfilled diamond )Aggregation ( an unfilled diamond ) Airport has AircraftAirport has Aircraft Aircraft is not part of AirportAircraft is not part of Airport

Aircraft

Jet Helicopter

Airport

Page 16: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1616Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Class Diagram – Class Diagram – has-ahas-a relationship relationship

Composition ( an filled diamond )Composition ( an filled diamond ) The contained object is a part of the containing objectThe contained object is a part of the containing object A Car has Tires as partsA Car has Tires as parts

Use relationshipUse relationship A dash line with an arrowA dash line with an arrow Also called dependencyAlso called dependency

relationshiprelationship

Car

Tire

Gas Station

Page 17: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1717Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Notes in the UMLNotes in the UML

A noteA note A box containing the messageA box containing the message

Aircraft

Jet Helicopter

Airport

open diamondsmean aggregation

Page 18: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1818Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

The Cardinality of the RelationshipThe Cardinality of the Relationship

How many aircraft does an airport have?How many aircraft does an airport have?

Aircraft

Jet Helicopter

Airport

open diamondsmean aggregation

0..1 0..*

Page 19: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

1919Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

The Cardinality of the RelationshipThe Cardinality of the Relationship

Car

Tire

Gas Station

Tires are on exactly one car.Tires are on exactly one car.

1

4..5

Page 20: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

2020Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

OutlineOutline

OverviewOverview

What is the UML?What is the UML?

Why use the UML?Why use the UML?

The class diagramThe class diagram

Interaction DiagramsInteraction Diagrams

SummarySummary

Page 21: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

2121Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Interactive DiagramInteractive Diagram

Class diagramsClass diagrams Static relationshipsStatic relationships

Interactive diagramsInteractive diagrams Showing how objects interact with each otherShowing how objects interact with each other Sequence diagramSequence diagram

The most common typeThe most common type

Reading from top to downReading from top to down Object:Class notationObject:Class notation

Page 22: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

2222Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

Sequence DiagramSequence Diagram

Page 23: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

2323Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

OutlineOutline

OverviewOverview

What is the UML?What is the UML?

Why use the UML?Why use the UML?

The class diagramThe class diagram

Interaction DiagramsInteraction Diagrams

SummarySummary

Page 24: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

2424Ku-Yaw ChangKu-Yaw Chang The Unified Modeling LanguageThe Unified Modeling Language

SummarySummary

Do not worry so much about creating Do not worry so much about creating diagrams the “right” way.diagrams the “right” way. If you think something needs to be said, use a If you think something needs to be said, use a

Note to say it.Note to say it. If you aren’t sure about an icon or a symbol If you aren’t sure about an icon or a symbol

and you have to look up to find out its and you have to look up to find out its meaning, include a note to explain it since meaning, include a note to explain it since others may be unclear about its meaning, too.others may be unclear about its meaning, too.

Go for clarity.Go for clarity.

Page 25: Chapter Two The UML – Unified Modeling Language Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information.

The EndThe End