1 Introduction Introduction to UML to UML DIAGRAMS & CLASS DIAGRAM DIAGRAMS & CLASS DIAGRAM Chapter 7,8 Chapter 7,8 主主主 主主主 : : 主主主 主主主 [email protected]. [email protected]. tw tw
Dec 24, 2015
11
Introduction to Introduction to UMLUML
DIAGRAMS & CLASS DIAGRAMDIAGRAMS & CLASS DIAGRAMChapter 7,8Chapter 7,8
主講人主講人 : : 許勝杰許勝杰[email protected]@rtpc06.ee.ncku.edu.tw
22
OutlineOutline
Different Views of a SystemDifferent Views of a System DiagramsDiagrams Structural DiagramsStructural Diagrams Behavioral DiagramsBehavioral Diagrams Class DiagramClass Diagram Examples : An ATM SystemExamples : An ATM System
33
Different Views of a SystemDifferent Views of a System
A view is a projection into the A view is a projection into the organization and structure of a organization and structure of a system’s model, focused on one system’s model, focused on one aspect of a system.aspect of a system.
Five most important views :Five most important views : Use case view: Use case view: force the shape of system.force the shape of system. Design view: Design view: function requirements.function requirements. Process view: Process view: concurrency,concurrency, synchronization.synchronization. Implementation view: Implementation view: component and files component and files
assemble the physical system.assemble the physical system. Deployment view: Deployment view: nodes form H/W topologynodes form H/W topology
44
DiagramsDiagrams
A diagram is a graphical projection A diagram is a graphical projection into the elements that make up a into the elements that make up a system.system.
Each diagram provides a view into Each diagram provides a view into the elements that make up the the elements that make up the system.system.
Structural diagrams to view the static Structural diagrams to view the static parts and Behavioral diagrams to parts and Behavioral diagrams to view the dynamic parts of a system.view the dynamic parts of a system.
55
Structural DiagramsStructural Diagrams
The UML’s structural diagrams are The UML’s structural diagrams are used to visualize, specify, construct, used to visualize, specify, construct, and document the and document the static aspectsstatic aspects of a of a system.system.
Static aspects: represent system’s Static aspects: represent system’s relatively stable skeleton and relatively stable skeleton and scaffolding.scaffolding.
UML’s four structural diagrams:UML’s four structural diagrams: Class diagramsClass diagrams Object diagramsObject diagrams Component diagramsComponent diagrams Deployment diagramsDeployment diagrams
66
Structure DiagramsStructure Diagrams - -Class DiagramsClass Diagrams
A class diagram shows a set of A class diagram shows a set of classes, interfaces, and classes, interfaces, and collaborations and their relationship.collaborations and their relationship.
Class diagrams are used to illustrate Class diagrams are used to illustrate the the static design view static design view of a system.of a system.
Class diagrams including active Class diagrams including active classes are used to address the classes are used to address the static process viewstatic process view of a system. of a system.
77
Structure DiagramsStructure Diagrams - -Object DiagramsObject Diagrams
A object diagram show a set of objects A object diagram show a set of objects and their relationships.and their relationships.
Object diagrams are used to illustrate Object diagrams are used to illustrate data structures, the static snapshots of data structures, the static snapshots of instances of the things founds in class instances of the things founds in class diagrams.diagrams.
Object diagrams address the Object diagrams address the static static design viewdesign view of a system just as do of a system just as do class diagrams, but from the class diagrams, but from the perspective of real or prototypical case.perspective of real or prototypical case.
Ref. P.196, Fig 14-1Ref. P.196, Fig 14-1
88
Structure DiagramsStructure Diagrams - -Component DiagramsComponent Diagrams
A component diagram shows a set A component diagram shows a set of components and their of components and their relationships.relationships.
Component diagrams are used to Component diagrams are used to illustrate illustrate static implementation static implementation viewview of a system. of a system.
A component typically maps to one A component typically maps to one or more classes, interfaces, or or more classes, interfaces, or collaborations.collaborations.
Ref. P.394, Fig.29-1Ref. P.394, Fig.29-1
99
Structure DiagramsStructure Diagrams - -Deployment DiagramsDeployment Diagrams
A deployment diagram shows a A deployment diagram shows a set of nodes and their set of nodes and their relationships.relationships.
Deployment diagrams illustrate Deployment diagrams illustrate the the static deployment viewstatic deployment view of an of an architecture.architecture.
Ref. P.408, Fig. 30-1Ref. P.408, Fig. 30-1
1010
Behavioral DiagramsBehavioral Diagrams
The UML’s behavioral diagrams are The UML’s behavioral diagrams are used to visualize, specify, construct, used to visualize, specify, construct, and document the dynamic aspects and document the dynamic aspects of a system.of a system.
Dynamic aspects: represent a Dynamic aspects: represent a system’s changing parts.system’s changing parts.
UML’s five behavioral diagramsUML’s five behavioral diagrams Use case diagramsUse case diagrams Sequence diagramsSequence diagrams Collaboration diagramsCollaboration diagrams Statechart diagramsStatechart diagrams Activity diagramsActivity diagrams
1111
Behavioral Diagrams-Behavioral Diagrams-Use Case DiagramUse Case Diagram
A use case shows a set of use A use case shows a set of use cases and actors and their cases and actors and their relationships.relationships.
Used to illustrate the static use Used to illustrate the static use case view of a system.case view of a system.
Especially important in organizing Especially important in organizing and modeling the behaviors of a and modeling the behaviors of a system.system.
1212
Behavioral Diagrams-Behavioral Diagrams-Sequence DiagramSequence Diagram
A sequence diagram is an interaction A sequence diagram is an interaction diagram that emphasizes the diagram that emphasizes the time time orderingordering of messages. of messages.
It shows a set of objects and the It shows a set of objects and the messages sent and received by those messages sent and received by those objects.objects.
Used to illustrate the dynamic view of Used to illustrate the dynamic view of a system.a system.
1313
Behavioral Diagrams-Behavioral Diagrams-Collaboration DiagramCollaboration Diagram
A collaboration diagram is an A collaboration diagram is an interaction diagram that emphasize interaction diagram that emphasize the structural organization of objects the structural organization of objects that send and receive messages.that send and receive messages.
It shows a set of objects, links among It shows a set of objects, links among those objects, and messages sent those objects, and messages sent and received by those objects.and received by those objects.
Used to illustrate dynamic view of a Used to illustrate dynamic view of a system.system.
14
1515
Behavioral Diagram-Behavioral Diagram-Statechart DiagramStatechart Diagram
A statechart diagram shows a state A statechart diagram shows a state machine, consisting of states, machine, consisting of states, transitions, events, and activities.transitions, events, and activities.
Especially important in modeling the Especially important in modeling the behavior of an interface, class, or behavior of an interface, class, or collaboration.collaboration.
It emphasizes the event-ordered It emphasizes the event-ordered behavior of an object, which is behavior of an object, which is especially useful in modeling reactive especially useful in modeling reactive systems.systems.
Illustrating dynamic view of a system.Illustrating dynamic view of a system.
16
Statechart Diagram (p.333) Activity Diagram (p.259)
1717
Behavioral Diagrams-Behavioral Diagrams-Activity DiagramActivity Diagram
An activity diagram shows the flow An activity diagram shows the flow from activity to activity within a system.from activity to activity within a system.
It shows a set of activities, the It shows a set of activities, the sequential or branching flow from sequential or branching flow from activity to activity, and objects that act activity to activity, and objects that act and are acted.and are acted.
Especially important in modeling the Especially important in modeling the function of a system.function of a system.
It emphasizes the flow of control It emphasizes the flow of control among objects.among objects.
1818
Class DiagramClass Diagram
Class diagram commonly contains the Class diagram commonly contains the following things:following things: ClassesClasses InterfacesInterfaces CollaborationsCollaborations Dependency, generalization, and Dependency, generalization, and
association relationships.association relationships. It may also contains notes and It may also contains notes and
constraints, packages or subsystemsconstraints, packages or subsystems
1919
Class DiagramClass Diagram
Example:Example:
Fig 8-1 p.106
2020
Class DiagramClass Diagram
A well-structured class diagramA well-structured class diagram Focused on communicating one aspect Focused on communicating one aspect
of a system’s static design viewof a system’s static design view Contain only elements that are essential Contain only elements that are essential
to understanding that aspectto understanding that aspect Provides detail consistent with its level Provides detail consistent with its level
of abstraction, with adornments that are of abstraction, with adornments that are essential for understandingessential for understanding
Is not so minimalist that it misinform Is not so minimalist that it misinform readers about important semantics.readers about important semantics.
2121
Class DiagramClass Diagram
When drawing a class diagram:When drawing a class diagram: Give name communicating its purpose.Give name communicating its purpose. Layout elements with minimal cross lineLayout elements with minimal cross line Semantically close, lay out close.Semantically close, lay out close. Use notes and color to draw attention to Use notes and color to draw attention to
important features of system.important features of system. Try not to show too many kinds of Try not to show too many kinds of
relationships.relationships.
2222
An Example – ATM SystemAn Example – ATM System
The ATM system.The ATM system. Model collaborationModel collaboration
Identify the mechanism.Identify the mechanism. Identify the classes, interface of Identify the classes, interface of
each mechanism.each mechanism. Use scenarios to walk through Use scenarios to walk through
these things.these things. Populate these elements with their Populate these elements with their
contents.contents.
23
An Example – ATM System
密碼
金額
金融卡
櫃員機
checkCard()
checkPW ()
getMoney()
顧客
inputCard()
inputPW()
inputMoney()
1..*1
11
1
1..*
24
Object Diagram
25
Component Diagram
26
Deployment Diagram