software design with uml - @@ home - kku web hosting overview • focuses on the object-oriented...

119
Software Design with UML by Somboon Patntirapong

Upload: nguyenlien

Post on 24-May-2018

224 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Software Design with UML

by Somboon Patntirapong

Page 2: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Course Overview

• Focuses on the Object-Oriented Analysis and Design (OOAD)

• Uses the UML as a tool for the OOAD modeling process

Page 3: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Software Requirements

• Java Runtime Environment (JRE)– Recommend Java SE DK 5

• Jude version 5 (UML Tool)

• Others UMLTools– ArgoUML, Poseidon, Visual Paradigm– IBM Rational, Borland Together, MagicDraw

Page 4: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Software Requirements

• References– Learning UML 2.0, Oreilly, Russ Miles, Kim Hamilton, 2006– Use Case Driven Object Modeling with UML—Theory

and Practice, Apress, Doug Rosenberg, Matt Stephens, 2007

– http://java.sun.com– www.omg.org

Page 5: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Course Outline

• Chapter 1: Introduction to OOAD and UML• Chapter 2: UseCase Diagram• Chapter 3: Activity Diagram• Chapter 4: Class Diagram• Chapter 5: Advanced Class Diagram• Chapter 6: Object Diagram• Chapter 7: Sequence Diagram• Chapter 8: Collaboration Diagram• Chapter 9: Component Diagram• Chapter 10: Deployment Diagram

Page 6: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Course Outline

• Chapter 11: Package Diagram• Chapter 12: State Diagram• Hand-on Case Study

Page 7: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 1

Introduction to OOAD and UML

Page 8: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Introduction to OOAD and UML

• Software Development Life Cycle– Requirements and Analysis

– Design

– Development

– Testing

– Deployment

Page 9: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Introduction to OOAD and UML

• Well-known Software Development Processes:– Waterfall

– Iterative

Page 10: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Introduction to OOAD and UML

• OOAD focuses on analysis and design phases– Use features of OO programing language

• UML as a tool (Modeling Language)– Why not model with code?

• What is Unified Modeling Language (UML)?– Notation

• Why UML?– Standard– Comprehensive and concise– Built on lessons learned

Page 11: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Introduction to OOAD and UML

• Degrees of UML– UML as a sketch– UML as a blueprint

• UML consists of diagrams:– UseCase– Activity– Class and Object– Sequence and Collaboration– State– Package– Component and Deployment

Page 12: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 2

UseCase Diagram

Page 13: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• Uses UseCase diagram to model the requirements• Is a starting point of project• Gives you a big picture• Shows who uses the system• Shows the features of the system

Page 14: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• Content Management System (CMS) case

• Requirement A1:The content management system shall allow an administrator

to create a new blog account, provided the personal details of the new blogger are verified using the author credentials database.

Page 15: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• Actor Element:

– Identifies who or what uses the use cases– Can be a person or a system

Page 16: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• Actor Element:

– Generalization/Specialization

Page 17: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• UseCase Element:

– Identifies required feature of the system

• Communication Line Element:– Connect an actor and a usecase

Page 18: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• System Boundaries Element:

Page 19: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• Requirement A2:

The content management system shall allow an administrator to create a new personal Wiki, provided the personal details of the applying author are verified using the author credentials database

Page 20: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• <<include>> Element:

– Incorporates behavior

Page 21: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• Special Case/Generalization Element:

Page 22: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

UseCase Diagram• <<extend>> Element:

– Not always, might or might not

Page 23: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 3

Activity Diagram

Page 24: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• UseCase diagram show what your system should do• Activity diagram show how your system will

accomplish it goals• Shows a procedure or workflow• Similar to flowchart

Page 25: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• Initial Node Element:– Starts the activity

• Action Element:– Actions are the active steps in the activity

Page 26: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• Flow Element:

• Final Node Element:

Page 27: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• Decisions and Merges Element:– Guard : [condition]

Page 28: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• Fork and Join Element:– Fork : simultaneous flow– Join : all incoming action must finish before proceed to the

next flow

Page 29: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• Object Node Element:– Objects can be passed between actions

Page 30: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• Signal Element:– Activity may involve external systems, people, or processes– Eg: authorizing credit card payment– Sending :– Receiving :

Page 31: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• Swimlane/Partition Element:– Used to differentiate the participants– Or to group the actions

Page 32: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

• Case Flow:– The administrator asks the system to create a new blog

account– The administrator selects an account type– The adminstrator enters the author’s details– The author’s details are verified using the author credentials

database– The new blog account is created– A summary of the new blog account’s details are emailed to

the author

• Draw your own one!!

Page 33: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Activity Diagram

Page 34: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 4

Class Diagram

Page 35: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Class diagram shows the classes that you must have to create a system

• So, what is a class?– Class is a blueprint of object

• Program must have at least one class• But normally more than one class (may be a

thousand)• What can the class contain?

– Attributes (Instance Variables)– Operations (Methods)– Constructors

Page 36: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Class Diagram:

Page 37: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Source code:public class Account{

private double balance;

public Account(double intiBalance){ balance = initBalance; } public boolean deposit(double amt){ .. } public boolean withdraw(double amt){ .. }}

Page 38: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Visibility– Private (-)

– Package (~) ( )

– Protected (#)

– Public (+)

• Note:– For Java, protected = package + subclass

Page 39: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Class Attributes:– Inline

– Association

Page 40: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Multiplicity:– 1 .. 1– 1 .. *– * .. 1– * .. *

Page 41: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Attribute Properties

• Source code:

public class CMS{ private final String createdBy = “James & Co..”; ..}

Page 42: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Class Operations:

Page 43: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Information Hiding– To protect our valuable information (data)– How?

• Encapsulation– We separate the system into many clasess (OO)– BUT each class has protected his own data!!– So, what should we do?

Page 44: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Information Hiding/Encapsulation– Can’t apply these concept separately– Otherwise useless!!

Page 45: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Class Diagram

• Static Members:

Page 46: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 5

Advanced Class Diagram

Page 47: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Classes can have relationships to one another• A class can be a type of another class; generalization• A class can contain objects of another class in

various way

• Class relationship:– Dependency (weakest)– Association– Aggregation– Composition– Inheritance (strongest)

Page 48: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Dependency– Dependency between two classes means one class needs

the other class– One class USES another class– Let say, A depends on B– If B changed, A needs to know the changes!!– If A changed, B doesn’t care

Page 49: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Source Code:

Public class UserInterface{ .. public void main(String args[]){ BlogEntry be = new BlogEntry(); be.setName(“My first blog”); .. }}

Page 50: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Association:– Means that a class will contain a reference to an object of

the other class– In form of an attribute– Relationship stronger than dependency

Page 51: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Source code:

public class BlogAccount{ private BlogEntry[] entries; ..}

public class BlogEntry{ ..}

Page 52: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Association with direction:– Can be unidirection– Or can be bidirection

Page 53: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Association class:– Resolves complex relationship (Many-to-Many)– Depends on object model

Page 54: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Aggregation:– Is just a stronger version of association– Owns but may share object of another class– Owned object may have a lifetime outside the owning object– Deletion of Project doesn’t imply that Employee must be

deleted

Page 55: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Source code:– For java, association and aggregation, coding is not different

public class Project{ private Employee[] emps; ..}

public class Employee{ ..}

Page 56: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Composition:– Kind of aggregation– But stronger than aggregation– Implies that owned objects can’t live without owning object– Eg, Introduction and MainBody don’t have meaning without

BlogEntry

Page 57: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Source code:– Association, Aggregation, and Composition, coding is the

same

public class BlogEntry{ private Introduction intro; private MainBody body; ..}

Page 58: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Generalization:– Inheritance– Is-A relationship or Kind-of relationship– Support multiple inheritance, but beware of conflicts

Page 59: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Source code:

public class Article{ ..}

public class BlogEntry extends Article{ ..}

Page 60: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Abstract Classes:– Classes that define functionality without providing full

implementation– Therefore can not be instantiated– Any class that extends an abstract class must implement

abstract method

Page 61: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Class that extends abstract class:

Page 62: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Source code:

public abstract class Store{ public abstract void store(Article[] articles); public abstract Article[] retrieve();}

public class BlogStore extends Store{ public void store(Article[] article){ .. } public Article[] retrieve(){ .. }}

Page 63: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Interface:– Like class that everything is abstract– Is not for extending, but for implementing– Avoids the problem of multiple inheritance– Methods listed in an interface are all abstract

Page 64: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Class that implements interface:

Page 65: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Advanced Class Diagram

• Source code:

public interface EmailSystem{ public abstract void send(Message msg);}

public class SMTPMailSystem implements EmailSystem{ public void send(Message msg){ .. }}

Page 66: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 6

Object Diagram

Page 67: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Object Diagram

• Objects are runtime representation of classes• Objects can be called Instances• Object diagram is very similar to a class diagram• Is useful when you want to describe how the objects

within the system work

Page 68: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Object Diagram

• Object can contain/show data:

Page 69: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Object Diagram

• Links:

Page 70: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 7

Sequence Diagram

Page 71: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Is a kind of interaction diagram• Shows interaction between parts of your system• Or identifies the objects involved with each process• Focuses on time sequence• One sequence relates directly to one usecase• You will know how well design of you classes with the

sequence diagram

Page 72: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Participants and Time Lines:– Usually the object– But can be an external system or people

Page 73: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Messages and Activation Bars:– Invoking methods/operations

Page 74: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Nested Messages:

Page 75: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Synchronous Messages:– Waits for response

Page 76: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Asynchronous Messages:– Don’t wait for a response– Eg, threading, messaging

Page 77: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Creation and Destruction Messages:

Page 78: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Creation Messages:– In Java, using new keyword– Eg, new Account(500);

• Destruction Messages:– In Java, doesn’t have to destroy object– Use garbage collector– So, check your preferred language– Implies no use of destruction message!!

Page 79: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Back to CMS case• Main flow:

– The administrator asks the system to create a new blog account

– The administrator selects the regular blog account type– The administrator enters the author’s details– The author’s details are checked using the author credential

database– The new regular blog account is created– A summary of the new blog account’s detailss are emailed to

the author• Just for review, because we already have the activity

diagram

Page 80: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Top-Level Sequence Diagram:

Page 81: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

• Detailed Sequence Diagram:– Contain more participants, more precise– But too much details may make the diagram complicated– Details may be the actual user interface of your choice

Page 82: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Sequence Diagram

Page 83: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 8

Collaboration Diagram

Page 84: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Collaboration Diagram

• Another kind of interaction diagram• Alternative to sequence diagram• Objects are concerned with numbered arrows

showing the flow of information• Focuses on link perspective• Called communication diagram in UML 2.0

Page 85: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Collaboration Diagram

• Participants, Links, and Messages:– Participants: objects, people, systems– Links: relationship– Messages: invoking methods (operations)

Page 86: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Collaboration Diagram

• Nested Messages:– The called method invokes others methods

Page 87: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Collaboration Diagram

• Invoking message multiple times:– Format: [i=0..9]

Page 88: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Collaboration Diagram

• Sending a message based on a condition:– Format: [condition=true]

Page 89: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Collaboration Diagram

• Back to CMS Case– Collaboration vs Sequence Diagrams

Page 90: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Collaboration Diagram

Page 91: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Collaboration Diagram

• Collaboration VS Sequence Diagrams– What do you think?– Which one do you prefer?

• Sometimes we need both!!

Page 92: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 9

Component Diagram

Page 93: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Component Diagram

• Component is a reusable part of your software• Eg, libraries

• Component diagram shows:– Packaging of code– Dependencies between components– Can show nested components

Page 94: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Component Diagram

• A basic component:

• Provided and Required Interfaces:

Page 95: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Component Diagram

• Using stereotype notation:– If you want to show the details of interfaces

Page 96: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Component Diagram

• Components working together:– Components usually work together with other components

Page 97: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Component Diagram

• Dependency:– Component depends on other components

Page 98: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Component Diagram

• Artifacts:– Can be libraries– In Java, JAR Files

Page 99: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 10

Deployment Diagrams

Page 100: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Deployment Diagram

• Shows the physical view of your system• Shows the physical relationships between hardware

components• Shows components within the nodes• Shows the protocol being used between nodes

Page 101: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Deployment Diagram

• Nodes:– Can be systems:– Eg, Application Server, Web Server, Operating System– Can be hardwares:– Eg, Server, Desktop PC

Page 102: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Deployment Diagram

• Communications:– Shows connection with protocols

Page 103: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Deployment Diagram

• Showing components:– Shows components that are deployed in the node

Page 104: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Deployment Diagram

• Node Instances:

Page 105: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 11

Package Diagrams

Page 106: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Package Diagram

• Used to grouping items especially classes• Also provides namespaces• Helps member visibility

• How good is system without packages?

Page 107: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Package Diagram

• Packages:– Like folder icon– In Java, directories

Page 108: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Package Diagram

• Contents of a package:– Usually classes– Nested packages, finally classes inside

Page 109: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Package Diagram

• Source Code:

package security;

public class Credential{ ..}

Page 110: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Package Diagram

• Showing class with its package (an alternative)

Page 111: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Package Diagram

• Package Dependency

Page 112: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Chapter 12

State Diagrams

Page 113: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

State Diagram

• Shows how one object changes over time• Helps understanding of the model• What shoud do/what should not do• Consists of:

– State– Event

• State diagram is heavily used in niches of software such as:– Embedded System– Real-time System

Page 114: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

State Diagram

• States:– Status of being at a certain time– Eg, light: on/off

Page 115: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

State Diagram

• Transitions:– Represents a change of states from a source state to a

target state– Event/Trigger makes transition

Page 116: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

State Diagram

• Complex Transitions:– Contains conditions or guards

Page 117: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

State Diagram

• Internal Transition/Action in State:– Entry, Do, Exit

Page 118: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

State Diagram

• Initial and Final State:– Starting and ending points

Page 119: Software Design with UML - @@ Home - KKU Web Hosting Overview • Focuses on the Object-Oriented Analysis and Design (OOAD) • Uses the UML as a tool for the OOAD modeling process

Software Design with UML

• What next?– Design pattern– GoF Design pattern– Enterprise pattern

• Hopefully, you like UML• Enjoy your drawing!!

Thank You,Somboon Patntirapong

Copyright 2007