What is a Class Diagram? Class Diagram. Why do we need Class Diagram? Class - Notation. Class - Semantic 04/11/51

Similar documents
What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships

Use Case Sequence Diagram. Slide 1

CSE 308. UML Sequence Diagrams. Reading / Reference.

Lesson 11. W.C.Udwela Department of Mathematics & Computer Science

Sequence Diagrams. Massimo Felici. Massimo Felici Sequence Diagrams c

UML Fundamental. OutLine. NetFusion Tech. Co., Ltd. Jack Lee. Use-case diagram Class diagram Sequence diagram

Object-Oriented Modeling. Sequence Diagram. Slides accompanying Version 1.0

INTRODUCTION TO UNIFIED MODELING MODEL (UML) & DFD. Slides by: Shree Jaswal

CS 370 REVIEW: UML Diagrams D R. M I C H A E L J. R E A L E F A L L

Meltem Özturan

Interactions A link message

Interaction Modelling: Sequence Diagrams

Object-Interaction Diagrams: Sequence Diagrams UML

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

UNIT-4 Behavioral Diagrams

UNIT-IV BASIC BEHAVIORAL MODELING-I

The learning objectives of this chapter are the followings. At the end of this chapter, you shall

Lecture 21 Detailed Design Dynamic Modeling with UML

Object Interaction Sequence Diagrams

LABORATORY 1 REVISION

SOFTWARE ENGINEERING UML FUNDAMENTALS. Saulius Ragaišis.

Unified Modeling Language

Software Specification 2IX20

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

Lecture 17: (Architecture V)

Basic Structural Modeling. Copyright Joey Paquet,

Software Service Engineering

UML Component Diagrams A.Y 2018/2019

UNIT I. 3. Write a short notes on process view of 4+1 architecture. 4. Why is object-oriented approach superior to procedural approach?

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

12 Tutorial on UML. TIMe TIMe Electronic Textbook

Stateflow Best Practices By Michael Burke

Object Oriented Methods with UML. Lecture -4

KF5008 Program Design & Development. Lecture 3 Sequence Diagrams

UML Diagrams MagicDraw UML Diagrams

APPENDIX M INTRODUCTION TO THE UML

Exercise Unit 2: Modeling Paradigms - RT-UML. UML: The Unified Modeling Language. Statecharts. RT-UML in AnyLogic

Question Sheet There are a number of criticisms to UML. List a number of these criticisms.

UML Tutorial. Unified Modeling Language UML Tutorial

UML- a Brief Look UML and the Process

Developing Shlaer-Mellor Models Using UML

State Machine Diagrams

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

Modeling with Activity Diagram

Sequence Diagram. A UML diagram used to show how objects interact. Example:

3: Modeling Behavior with UML Sequence Diagrams

Applying UML & Patterns (3 rd ed.) Chapter 15

Unified Modeling Language (UML)

Introduction to Unified Modelling Language (UML)

Modeling Dynamic Behavior

UML Primer. -Elango Sundaram

CS211 Lecture: Modeling Dynamic Behaviors of Systems; Interaction Diagrams and Statecharts Diagrams in UML

Introduction to Software Engineering. 6. Modeling Behaviour

UML part I. UML part I 1/41

Pieter van den Hombergh. Fontys Hogeschool voor Techniek en Logistiek. September 9, 2016

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

Lexical Considerations

UML 2.0 UML 2.0. Scott Uk-Jin Lee. Division of Computer Science, College of Computing Hanyang University ERICA Campus

Sequence Diagram. r: Register s: Sale

PROCESSES AND THREADS

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER

Chapter 2: The Object-Oriented Design Process

UML Sequence Diagrams

1 Lexical Considerations

Course "Softwaretechnik" Book Chapter 2 Modeling with UML

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

Software Engineering. Page 1. Objectives. Object-Behavioural Modelling. Analysis = Process + Models. Case Study: Event Identification

CS211 Lecture: Modeling Dynamic Behaviors of Systems; Interaction Diagrams in UML

7. UML Sequence Diagrams Page 1 of 1

Advanced Interaction

7 The proposed domain specific language: operational level

Lab Manual. Object Oriented Analysis And Design. TE(Computer) VI semester

Ali Khan < Project Name > Design Document. Version 1.0. Group Id: S1. Supervisor Name: Sir.

STATE MACHINES. Figure 1: State Machines

COSC 3351 Software Design. An Introduction to UML (I)

Unified Modeling Language (UML) Object Diagram and Interaction Diagrams

In This Lecture You Will Learn: Specifying Control. Statechart. Event, State and Transition

Object Oriented Modeling

Chapter 3: Object Oriented Design

OMG Modeling Glossary B

Object-Oriented and Classical Software Engineering

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

OBJECT ORIENTED DESIGN with the Unified Process. Use Case Realization

MSc programme (induction week) Department of Informatics INTRODUCTION TO UML

UML Sequence Diagrams for Process Views

CSE 403. UML Sequence Diagrams. Reading: UML Distilled Ch. 4, by M. Fowler

Activity Diagram Written Date : September 02, 2016

Advanced Software Engineering

UML Behavioral Models

Modeling Dynamic Behavior

Introduction to Programming Using Java (98-388)

Specifying Precise Use Cases with Use Case Charts

UML class diagrams. Nigel Goddard. School of Informatics University of Edinburgh

Java Programming Training for Experienced Programmers (5 Days)

UML REFERENCE SHEETS. 2013, 2014 Michael Marking; all rights reserved, including moral rights. Web site:

Object Oriented Design. Program Design. Analysis Phase. Part 2. Analysis Design Implementation. Functional Specification

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

Lexical Considerations

CSE 230 Intermediate Programming in C and C++ Functions

OBJECT ORIENTED DESIGN with the Unified Process. Use Case Realization

Transcription:

What is a Class Diagram? Class Diagram A diagram that shows a set of classes, interfaces, and collaborations and their relationships Why do we need Class Diagram? Focus on the conceptual and specification perspectives to avoid the premature implementation perspective p all the time during your projects We can show the static structure of the things that exist, their internal structure, and their relationships to other things What are the main components of a Class Diagram? Class Class name Attribute Operation Relationships Generalization Association Aggregation Dependency Class - Semantic Class - Notation A class is the descriptor for a set of objects with similar structure, behavior, and relationships Classes are declared in class diagrams and used in most other diagrams. The name of a class has scope within the package in which it is declared. The name must be unique among class names within its package 1

Drawing a Class Attributes - Semantic At the conceptual level, it is equivalent to a composition association Attributes are always single-valued Any type used as an attribute has value rather than references Attribute - Notation Operation Semantic & Notation Generalization A relationship between a general thing and a more specific kind of that thing is-a-kind-of relationship Generalization Semantic & Notation 2

Association A structural relationship that specifies that objects of one thing are connected to objects of other At the conceptual level, associations represent conceptual relationships between classes At the specification level, associations represent responsibilities At the implementation level, associations represent navigability. Association - Example Association Role name Each association has two roles; each role is a direction on the association A role can be explicitly named with a label. It there is no label, l you name a role after the target class Multiplicity Navigability Aggregation/Composition indicators Ordering Association Dependency A using relationship that states that a change in specification of one thing may affect another thing that uses it, but not necessarily the reverse One class uses another class as an argument in the signature of an operation Sequence Diagram 3

A First Look at Sequence Diagrams Illustrates how objects interacts with each other. Emphasizes time ordering of messages. Can model simple sequential flow, branching, iteration, recursion and concurrency. Sequence Diagram Interaction diagrams come in two forms, both present in the UML. The first form is the sequence diagram. In this form objects are shown as vertical lines with the messages as horizontal lines between them. This form was first popularized by Jacobson A Sequence Diagram A Sequence Diagram borrow(book) member: LibraryMember ok = mayborrow() [ok] borrow(member) book:book settaken(member) :Book Copy Y-Axis (time) borrow(book) message member: LibraryMember X-Axis (objects) ok = mayborrow() [ok] borrow(member) condition book:book Life Line settaken(member) :Book Copy Object Activation box Object Object naming: syntax: [instancename][:classname] Name classes consistently with your class diagram (same classes). Include instance names when objects are referred to in messages or when several objects of the same type exist in the diagram. The Life-Line represents the object s life during the interaction mybirthdy :Date Lifeline Samples 4

Messages Messages (Cont.) An interaction between two objects is performed as a message sent from one object to another. Most often implemented by a simple operation call. Can be an actual message sent through some communication mechanism, either over the network or internally on a computer. Inter-process communication (Signaling, ) Remote Procedure Call (RMI, CORBA, ) If object obj 1 sends a message to another object obj 2 an association must exist between those two objects: Structural dependency obj 2 is in the global scope of obj 1 obj 2 is in the local scope of obj 1 (method argument) obj 1 and obj 2 are the same object Messages (Cont.) Message Types A message is represented by an arrow between the life lines of two objects. Self calls are also allowed The time required by the receiver object to process the message is denoted by an activationbox. A message is labeled at minimum with the message name. Arguments and control information (conditions, iteration) may be included. Prefer using a brief textual description whenever an actor is the source or the target of a message. Synchronous Asynchronous Simple Create Destroy <<create>> <<destroy>> Synchronous Messages Return Values Nested flow of control, typically implemented as an operation call. The routine that handles the message is completed before the caller resumes execution. Caller Blocked :A :B doyouunderstand() yes return (optional) Optionally indicated using a dashed arrow with a label indicating the return value. Don t model a return value when it is obvious what is being returned, e.g. gettotal() Model a return value only when you need to refer to it elsewhere, e.g. as a parameter passed in another message. Prefer modeling return values as part of a method invocation, e.g. ok = isvalid() 5

Object Creation An object may create another object via a <<create>> message. :A :B :A Preferred Object Destruction An object may destroy another object via a <<destroy>> message. An object may destroy itself. Avoid modeling object destruction unless memory management is critical. <<create>> <<create>> :B :A :B <<destroy>> Constructor Asynchronous Messages Used for modeling concurrent systems. Caller does not wait for the message to be handled before it continues to execute. As if the call returns immediately Active objects own an execution thread and can initiate control activity. An asynchronous message can: Create a new thread (a new activation record) Create a new object Communicate with a thread that is already running. Control information Condition syntax: [ expression ] message-label The message is sent only if the condition is true [ok] borrow(member) example: Iteration syntax: * [ [ expression ] ] message-label The message is sent many times to possibly multiple receiver objects. Control Information (Cont.) Iteration examples: :CompoundShape :Shape :Driver draw() *draw() *[until full] insert() The syntax of expressions is not a standard :Bus Control Information (Cont.) The control mechanisms of sequence diagrams suffice only for modeling simple alternatives. Consider drawing several diagrams for modeling complex scenarios. Don t use sequence diagrams for detailed modeling of algorithms (this is better done using activity diagrams, pseudo-code or state-charts). 6

Frame Element Frame Element is the optional graphical boundary of a diagram A frame element provides a consistent place for a diagram's label, while providing a graphical boundary for the diagram The diagram's label is placed in the top left corner, called the frame's "namebox," a sort of dog-eared rectangle, and the actual UML diagram is defined d within the body of the larger enclosing rectangle. Incoming and Outgoing Message at the border of the frame element On sequence diagrams incoming and outgoing messages (a.k.a. interactions) for a sequence can be modeled by connecting the messages to the border of the frame element Message Sample Lost and Found Message UML 2.0 introduced the concept of messages that do not reach their destination (lost messages)or are from unknown sources (found messages) Note that lost and found are relative terms ; the receiver or sender might only be unknown with respect to your current sequence diagram Lost messages are commonly used to show how a system handles a network failure resulting in an undelivered message Found messages are commonly used for modeling exception handling you don t necessarily care who threw the exception ; you simply want to show how it is handled Combined The sequence diagrams are not intended for showing complex procedural logic However, there are a number of mechanisms that do allow for adding a degree of procedural logic to diagrams and which come under the heading of combined fragments. A combined fragment is one or more processing sequence enclosed in a frame and executed under specific named circumstances. The fragments available are: Alternative fragment (denoted alt ) models if then else constructs. Option fragment (denoted opt ) models switch constructs. Break fragment models an alternative sequence of events that is processed instead of the whole of the rest of the diagram. Parallel fragment (denoted par ) models concurrent processing. Consider fragment is in effect the opposite of the ignore fragment: any message not included in the consider fragment should be ignored. Loop fragment encloses a series of messages which are repeated. 7

Alternative Alternatives are used to designate a mutually exclusive choice between two or more message sequences Alternatives allow the modeling of the classic "if then else" logic Option The option combination fragment is used to model a sequence that, given a certain condition, will occur; otherwise, the sequence does not occur An option is used to model a simple "if then" statement Loop The loop in the sequence diagram uses a Boolean test to verify if the loop sequence should be run When you get to the loop combination fragment a test is done to see if the value of the entry condition is true. Then the sequence goes into the loop fragment Loop Fragment Reference Referenced Sequence Diagram (It is reusable) The text "ref" is placed inside the frame's namebox, and the name of the sequence diagram being referenced is placed inside the frame's content area along with any parameters to the sequence diagram 8

Gate A gate is a connection point for connecting a message inside a fragment with a message outside a fragment A gate as a small square on a fragment frame Diagram gates act as off-page connectors for sequence diagrams, representing the source of incoming messages or the target of outgoing messages Break When a break combined fragment's message is to be executed, the enclosing interaction's remainder messages will not be executed because the sequence breaks out of the enclosing interaction Once all the messages in the break combination have been sent, the sequence exits without sending any of the remaining messages In this way the break combined fragment is much like the break keyword in a programming language like C++ or Java. Parallel The parallel combination fragment is drawn using a frame, and you place the text "par" in the frame's namebox The frame is divided into content sections, separated by a dashed line Each interaction in the frame represents a thread of execution done in parallel 9