chapter two the uml – unified modeling language ku-yaw chang [email protected] assistant...

25
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

Upload: sophia-foster

Post on 03-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

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

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

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

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

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)

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

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

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

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

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

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

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 (-)

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.

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

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

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

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

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..*

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

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

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

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

Sequence DiagramSequence Diagram

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

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.

The EndThe End