c++ training datascope lawrence d’antonio lecture 11 uml

48
Datascope Datascope Lawrence Lawrence D’Antonio D’Antonio Lecture 11 Lecture 11 UML UML

Post on 21-Dec-2015

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

C++ TrainingC++ TrainingDatascopeDatascope

Lawrence D’AntonioLawrence D’AntonioLecture 11Lecture 11

UMLUML

Page 2: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

What is UML?What is UML?

UML is a language for UML is a language for visualizingvisualizing. It allows . It allows the designer to express the model for a the designer to express the model for a system in graphical language.system in graphical language.

UML is a language for UML is a language for specifyingspecifying. It . It specifies all analysis, design and specifies all analysis, design and implementation decisions in constructing a implementation decisions in constructing a system.system.

Page 3: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

What is UML? 2What is UML? 2

UML is a language for UML is a language for constructingconstructing. It . It should be possible to map from a model in should be possible to map from a model in UML into an implementation language.UML into an implementation language.

UML is a language for UML is a language for documentingdocumenting. It . It documents artifacts such as requirements, documents artifacts such as requirements, architecture, design, source code, architecture, design, source code, prototypes, and testing.prototypes, and testing.

Page 4: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Building BlocksUML Building Blocks

There are three kinds of building blocks in There are three kinds of building blocks in UML.UML.

ThingsThings RelationshipsRelationships DiagramsDiagrams

Page 5: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML ThingsUML Things

Structural thingsStructural things Behavioral thingsBehavioral things Grouping thingsGrouping things Annotational thingsAnnotational things

Page 6: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML StructuresUML Structures

StructuresStructures. Different types of UML structures . Different types of UML structures are:are:

Classes.Classes. A class has attributes, operations, A class has attributes, operations, and relationships.and relationships.

Page 7: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Window ClassWindow Class

+open()+close()+move()+display()

-origin-size

Window

Page 8: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Structures 2UML Structures 2

Interfaces.Interfaces. A collection of operations that A collection of operations that specify a service of a class or component.specify a service of a class or component.

Page 9: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Window InterfaceWindow Interface

IWindow

+open()+close()+move()+display()

«interface»IWindow

Window

Page 10: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Structures 3UML Structures 3

Collaboration Diagram.Collaboration Diagram. Defines an Defines an interaction and a collection of roles and interaction and a collection of roles and other elements that work together to other elements that work together to provide some cooperative behavior.provide some cooperative behavior.

Page 11: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Collaboration DiagramCollaboration Diagram

ElementElement SymbolSymbol

Object:Object: The objects interacting with each The objects interacting with each other in the system. Depicted by a rectangle other in the system. Depicted by a rectangle with the name of the object in it, preceded with the name of the object in it, preceded by a colon and underlined.by a colon and underlined.

Relation/Association:Relation/Association: A link connecting A link connecting the associated objects. Qualifiers can be the associated objects. Qualifiers can be placed on either end of the association to placed on either end of the association to depict cardinality.depict cardinality.

Messages:Messages: An arrow pointing from the An arrow pointing from the commencing object to the destination object commencing object to the destination object shows the interaction between the objects. shows the interaction between the objects. The number represents the order/sequence The number represents the order/sequence of this interaction.of this interaction.

Page 12: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Course Management ExampleCourse Management Example

An organization that offers a variety of An organization that offers a variety of courses needs to create a courseware courses needs to create a courseware management system.management system.

Each course is made up of a set of topics. Each course is made up of a set of topics. Tutors in the organization are assigned Tutors in the organization are assigned

courses to teach according to the area that courses to teach according to the area that they specialize in and their availability. they specialize in and their availability.

Page 13: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 2Example 2

The organization publishes and maintains The organization publishes and maintains a calendar of the different courses and the a calendar of the different courses and the assigned tutors every year. assigned tutors every year.

There is a group of course administrators There is a group of course administrators in the organization who manage the in the organization who manage the courses including course content, assign courses including course content, assign courses to tutors, and define the course courses to tutors, and define the course schedule. schedule.

Page 14: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 3Example 3

System objects:System objects: Course AdministratorCourse Administrator CourseCourse TopicTopic TutorTutor UserUser

Page 15: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 4Example 4

Manage Course Information ScenarioManage Course Information Scenario A user who is a course administrator A user who is a course administrator

invokes the manage course functionality. invokes the manage course functionality. The manage course functionality of the The manage course functionality of the

course administrator invokes either the course administrator invokes either the course creation or course modification course creation or course modification functionality of a course. functionality of a course.

Page 16: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 5Example 5

After the course is either created or After the course is either created or modified, the manage topic functionality of modified, the manage topic functionality of the course administrator calls the topic the course administrator calls the topic creation or modification functionality of a creation or modification functionality of a topic. topic.

Finally, the user invokes the assign tutor to Finally, the user invokes the assign tutor to course functionality of the course course functionality of the course administrator to assign a tutor to the administrator to assign a tutor to the selected course. selected course.

Page 17: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 6Example 6

Page 18: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Another exampleAnother example

Page 19: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Structures 4UML Structures 4

Use Case.Use Case. This is a description of sequences of This is a description of sequences of actions that a system performs relevant to actions that a system performs relevant to particular actors who interact with the system.particular actors who interact with the system.

The Use case diagram is used to identify the The Use case diagram is used to identify the primary elements and processes that form the primary elements and processes that form the system. The primary elements are termed as system. The primary elements are termed as "actors" and the processes are called "use "actors" and the processes are called "use cases." The Use case diagram shows which cases." The Use case diagram shows which actors interact with each use case. actors interact with each use case.

Page 20: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Elements of Use CasesElements of Use Cases

Actors:Actors: An actor portrays any entity (or An actor portrays any entity (or entities) that performs certain roles in a entities) that performs certain roles in a given system. An instance of an actor given system. An instance of an actor represents an individual interacting with represents an individual interacting with the system in a specific way. For example, the system in a specific way. For example, in a banking system there may be actors in a banking system there may be actors named Loan Officer and Customer. Actors named Loan Officer and Customer. Actors are active participants in the system.are active participants in the system.

Page 21: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Use Case:Use Case: A use case in a use case diagram is a description of a set of sequences of actions, including variants, that a system performs to yield an observable result of value to an actor. Graphically, a use case is represented as an ellipse. For example, in an ATM ValidateUser may be one use case.

Page 22: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Courseware exampleCourseware example

Who are the actors in the courseware Who are the actors in the courseware management system?management system?

Course AdministratorCourse Administrator TutorTutor StudentStudent

Page 23: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 2Example 2

What are the use cases for the courseware What are the use cases for the courseware management system?management system?

View coursesView courses Manage course informationManage course information Manage topics for a courseManage topics for a course View course calendarView course calendar View tutorsView tutors Manage tutor informationManage tutor information Assign courses to tutorsAssign courses to tutors

Page 24: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 3Example 3

Page 25: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Another exampleAnother example

Page 26: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Structures 5UML Structures 5

Active Class.Active Class. These is a class whose objects These is a class whose objects own one or more processes or threads and own one or more processes or threads and therefore can initiate control activity.therefore can initiate control activity.

+suspend()+flush()

Event Manager

Page 27: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Structures 6UML Structures 6

Component.Component. This is a modular part of the This is a modular part of the system design that hides its system design that hides its implementation behind a set of external implementation behind a set of external interfaces.interfaces.

An interface that a component realizes is An interface that a component realizes is called a called a provided interfaceprovided interface. .

An interface that a component uses is An interface that a component uses is called a called a required interfacerequired interface..

Page 28: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Simple exampleSimple example

Page 29: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 2Example 2

In this example there are three In this example there are three components: Order System, Inventory components: Order System, Inventory System, Customer Repository.System, Customer Repository.

The Order System requires an interface The Order System requires an interface for customer lookup. This interface is for customer lookup. This interface is provided by the Customer Repository.provided by the Customer Repository.

Page 30: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Courseware exampleCourseware example

We may wish to group together classes We may wish to group together classes such as CourseAdministrator, Course, such as CourseAdministrator, Course, Topic, and Student in a Model layer.Topic, and Student in a Model layer.

We will need to provide a consistent We will need to provide a consistent interface to enable other classes and interface to enable other classes and components to interact with them and components to interact with them and utilize their services. utilize their services.

Page 31: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 2Example 2

Page 32: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Structures 7UML Structures 7

Node.Node. This is a physical element that This is a physical element that exists at run time and represents a exists at run time and represents a computational resource (usually having computational resource (usually having memory and processing capability).memory and processing capability).

Page 33: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Structures 8UML Structures 8

Deployment Diagram.Deployment Diagram. A deployment A deployment diagram shows a set of nodes and their diagram shows a set of nodes and their relationships. They illustrate the static view relationships. They illustrate the static view of an architecture. Deployment diagrams of an architecture. Deployment diagrams are related to component diagrams in that are related to component diagrams in that a node typically encloses one or more a node typically encloses one or more components.components.

Page 34: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

ExampleExample

Page 35: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

Example 2Example 2

Page 36: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML BehaviorsUML Behaviors

UML behaviors are the verbs of a model. UML behaviors are the verbs of a model. There are three primary types of behaviors There are three primary types of behaviors in UML: interactions, state machines, and in UML: interactions, state machines, and actions. actions.

Page 37: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 2UML Behaviors 2

Interactions. Represents messages Interactions. Represents messages passed among a set of objects, in order to passed among a set of objects, in order to achieve a particular purpose.achieve a particular purpose.

In an interaction diagram the focus is on In an interaction diagram the focus is on the set of objects that interact in a system.the set of objects that interact in a system.

Page 38: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 3UML Behaviors 3

Sequence diagramSequence diagram

Page 39: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 4UML Behaviors 4

Collaboration diagramCollaboration diagram

Page 40: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 5UML Behaviors 5

State machine. Represents the series of State machine. Represents the series of states an object goes through in its states an object goes through in its lifetime, in response to different events. lifetime, in response to different events.

A state machine consists of states A state machine consists of states (rendered as a rounded rectangle), (rendered as a rounded rectangle), transitions (the flow between states), transitions (the flow between states), events (that trigger a transition), and events (that trigger a transition), and activities (the response to a transition).activities (the response to a transition).

Page 41: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 6UML Behaviors 6

In a state machine the focus is on the life In a state machine the focus is on the life cycle of a single object.cycle of a single object.

Page 42: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 7UML Behaviors 7

State machine for enrolling a seminar.State machine for enrolling a seminar.

Page 43: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 8UML Behaviors 8

Complete seminar life cycle.Complete seminar life cycle.

Page 44: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 9UML Behaviors 9

In a UML activity the focus is on the In a UML activity the focus is on the sequence of actions taken.sequence of actions taken.

Each action is rendered as a rounded Each action is rendered as a rounded rectangle.rectangle.

Page 45: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Behaviors 10UML Behaviors 10

Activity Activity diagram. diagram. Workflow for Workflow for an order an order processing processing system.system.

Page 46: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML GroupingsUML Groupings

The primary construct in UML for grouping The primary construct in UML for grouping things is the package.things is the package.

A package is a general purpose A package is a general purpose mechanism for organizing the design, as mechanism for organizing the design, as opposed to classes that organize opposed to classes that organize implementation constructs.implementation constructs.

Packages may include in type of UML Packages may include in type of UML things.things.

Page 47: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Groupings 2UML Groupings 2

A class package diagram groups classes A class package diagram groups classes together that are related by inheritance, together that are related by inheritance, composition, or collaboration. composition, or collaboration.

A data package diagram organizes data A data package diagram organizes data entities.entities.

A use case package diagram represents a A use case package diagram represents a high level view of a use case.high level view of a use case.

Page 48: C++ Training Datascope Lawrence D’Antonio Lecture 11 UML

UML Groupings 3UML Groupings 3

Use case diagram package.Use case diagram package.