Lecture#03, uml diagrams

38
By: Altaf Hussain SS KRL BS(CS), AU Peshawar, MS(CSE), NUST Islamabad

description

 

Transcript of Lecture#03, uml diagrams

Page 1: Lecture#03, uml diagrams

By: Altaf Hussain

SS KRLBS(CS), AU Peshawar, MS(CSE), NUST Islamabad

Page 2: Lecture#03, uml diagrams

Modeling and documenting may often seem tedious and boring but they are essential for

helping to reduce complexity and thus building better software systems!

Page 3: Lecture#03, uml diagrams

The Unified Modeling Language (UML) is a standard  language for

Specifying Visualizing Constructing Documenting

Business Modeling Communications

Page 4: Lecture#03, uml diagrams

Users Designers Analyzers

Page 5: Lecture#03, uml diagrams

Standard Diagrams in UML• Structural Diagrams Class Diagram Object Diagram Component Diagram Deployment Diagram

• Behavioral Diagrams Use Case Diagram Sequence Diagram Collaboration Diagram Statechart Diagram Activity Diagram

Page 6: Lecture#03, uml diagrams
Page 7: Lecture#03, uml diagrams

• Class diagrams identify the class structure of a system, including the properties and methods of each class. Also depicted are the various relationships that can exist between classes, such as an inheritance relationship.

• Class• Association• Composition• Dependency• Aggregation• Generalization

Page 8: Lecture#03, uml diagrams

Class• A Class is depicted using a rectangle divided into three sections.

The top section is the name of the Class. The middle section defines the properties of the Class. The bottom section lists the methods of the class.

Association• An Association is a generic relationship between two classes, and is

modeled by a line connecting the two classes. This line can be qualified with the type of relationship, and can also feature multiplicity rules (e.g. one-to-one, one-to-many, many-to-many) for the relationship.

Composition• If a class cannot exist by itself, and instead must be a member of

another class, then that class has a Composition relationship with the containing class.

Dependency• When a class uses another class, perhaps as a member variable or

a parameter, and so "depends" on that class, a Dependency relationship is formed.

Page 9: Lecture#03, uml diagrams

Aggregation• Aggregations indicate a whole-part relationship, and are known as

"has-a" relationships. An aggregation has a diamond end pointing to the part containing the whole.

Generalization• A Generalization relationship is the equivalent of an inheritance

relationship in object-oriented terms (an "is-a" relationship). A Generalization relationship is indicated by an arrow with a hollow arrowhead pointing to the base, or "parent", class.

Example• Consider the example of a verterinary system. Animals served,

such as dogs and birds, are tracked along with their owners.

Page 10: Lecture#03, uml diagrams
Page 11: Lecture#03, uml diagrams

Example• Consider the example of a veterinary system. Animals served, such

as dogs and birds, are tracked along with their owners.

Page 12: Lecture#03, uml diagrams

Class diagrams show the classes of the system, their interrelationships (including inheritance, aggregation, and association), and the operations and attributes of the classes.

Name

Attributes

Operations

Relations

• Associations• Aggregation

• Generalization

Page 13: Lecture#03, uml diagrams

A CRC card is an index card that is use to represent the responsibilities of classes and the interaction between the classes.

The cards are created through scenarios, based on the system requirements, that model the conceptual view of the system.

Page 14: Lecture#03, uml diagrams

Example

Page 15: Lecture#03, uml diagrams

Object diagrams model instances of classes. This type of diagram is used to describe the system at a particular point in time.

Object• Objects are identified by placing the instance name followed by a

colon (:) in front of the class name. Property values are written as "name=value" pairs. The icon for an object is a rectangle divided into sections.

Association• Object diagrams can contain associations as well. Often, the

constraints, relationship details, and multiplicity rules found in the Class diagram are left out to concentrate the diagram on the Objects and their properties.

Page 16: Lecture#03, uml diagrams

Example• We'll consider the case of John, a pet lover from Boston, MA

and client of the veterinary hospital. He has two pets, Rover, a dog, and Tweety, a bird.

Page 17: Lecture#03, uml diagrams

Use Case diagrams identify the functionality provided by the system (use cases), the users who interact with the system (actors), and the association between the users and the functionality

Use Cases are used in the Analysis phase of software development to articulate the high-level requirements of the system.

The primary goals of Use Case diagrams include: Providing a high-level view of what the system does Identifying the users ("actors") of the system Determining areas needing human-computer interfaces

Page 18: Lecture#03, uml diagrams

Actor• An Actor is a user of the system

Use Case• A Use Case is functionality provided by the system, typically described as

verb+object (eg. Register Car, Delete User).

Association• Associations are used to link Actors with Use Cases, and indicate

that an Actor participates in the Use Case in some form.

Page 19: Lecture#03, uml diagrams

Use Case Diagram: Graphical Notation• A user placing an order with a sales company might follow these

steps. 

Page 20: Lecture#03, uml diagrams

Use Case Diagram: Text Notation

Create Bug Report (Paragraph Version)• The Tester initiates a new bug report. The Tester

indicates the source of the bug, a description of the problem, and the person to whom the bug should be assigned. The System records the bug as an open issue, and notifies the Assigned Person that a new bug has been submitted.

Page 21: Lecture#03, uml diagrams

Create Bug Report (Template Version)• Primary Actor: Tester• Goal in Context: Tester is testing an application and discovers a

new bug. He/She wants to report it so that it can be addressed.• Scope: System - the quality assurance system for the XYZ

Application• Level: User• Stakeholders and Interests: • Tester: wants to record a new bug

Assignee: wants to be notified of any new bugsQA Manager: wants all bugs recorded

• Precondition: none• Trigger: Tester discovers a bug while testing an application• Main Success Scenario: • 1. Tester initiates a new bug report.

2. System records bug with date of submission.3. System notifies assigned user.

• Extensions:1 a. Tester does not know who to assign bug report to: System assigns bug to QA Manager.

Page 22: Lecture#03, uml diagrams

Sequence diagrams document the interactions between classes to achieve a result, such as a use case. These communications between classes are known as messages.

The Sequence diagram lists objects horizontally, and time vertically, and models these messages over time.

Object• Objects are instances of classes, and are arranged horizontally.

Actor• Actors can also communicate with objects, so they too can be listed

as a column. Lifeline

• The LifeLine identifies the existence of the object over time. Activation

• Activations, modeled as rectangular boxes on the lifeline, indicate when the object is performing an action.

Message• Messages, modeled as horizontal arrows between Activations,

indicate the communications between objects.

Page 23: Lecture#03, uml diagrams

Hotel Reservation Example

Page 24: Lecture#03, uml diagrams

A sequence diagram is An interaction diagram

that details how operations are carried out.

What messages are sent and when.

Sequence diagrams are organized according to time

Object: Class

Lifeline

Operations

Message

Page 25: Lecture#03, uml diagrams
Page 26: Lecture#03, uml diagrams

Collaboration Diagrams describe interactions among classes and associations. These interactions are modeled as exchanges of messages between classes through their associations. Collaboration diagrams are a type of interaction diagram. Collaboration diagrams contain the following elements.

• Class roles, which represent roles that objects may play within the interaction.

• Association roles, which represent roles that links may play within the interaction.

• Message flows, which represent messages sent between objects via links. Links transport or implement the delivery of the message.

Page 27: Lecture#03, uml diagrams
Page 28: Lecture#03, uml diagrams

State chart (or state) diagrams describe the states and responses of a class. Statechart diagrams describe the behavior of a class in response to external stimuli. These diagrams contain the following elements:

• States, which represent the situations during the life of an object in which it satisfies some condition, performs some activity, or waits for some occurrence.

• Transitions, which represent relationships between the different states of an object.

Page 29: Lecture#03, uml diagrams
Page 30: Lecture#03, uml diagrams

A State Machine diagramshows the possible states ofthe object and the transitionsthat cause a change in state.

?What is different between activities and Statemachine diagram

Page 31: Lecture#03, uml diagrams

Activity diagrams describe the activities of a class. These diagrams are similar to statechart diagrams and use similar conventions, but activity diagrams describe the behavior of a class in response to internal processing rather than external events as in statechart diagram.

• Swimlanes, which represent responsibilities of one or more objects for actions within an overall activity; that is, they divide the activity states into groups and assign these groups to objects that must perform the activities.

• Action States, which represent atomic, or noninterruptible, actions of entities or steps in the execution of an algorithm.

• Action flows, which represent relationships between the different action states of an entity.\

• Object flows, which represent the utilization of objects by action states and the influence of action states on objects.

Page 32: Lecture#03, uml diagrams
Page 33: Lecture#03, uml diagrams

Activity diagrams describe the workflow behaviour of a system

Start

Fork

Branch

MergeJoint

End

Page 34: Lecture#03, uml diagrams

Component diagrams describe the organization of and dependencies among software implementation components. These diagrams contain components, which represent distributable physical units, including source code, object code, and executable code.

Page 35: Lecture#03, uml diagrams
Page 36: Lecture#03, uml diagrams

Deployment diagrams describe the configuration of processing resource elements and the mapping of software implementation components onto them. These diagrams contain components and nodes, which represent processing or computational resources, including computers, printers, etc.

Page 37: Lecture#03, uml diagrams
Page 38: Lecture#03, uml diagrams