26252990 uml complete

163
1 Object Oriented Analysis and Design Using UML 

Upload: nikki17

Post on 30-May-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 1/163

1

Object Oriented Analysis andDesign Using UML 

Page 2: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 2/163

2

Course description:

OBJECTIVE:

The understand the Unified Modeling Language and orient towards Object

Oriented methodology using UML for modeling software systems.

TARGET AUDIENCE:

In particular, it is intended for software professionals who have soundknowledge of object concepts and some experience towards analysis and design.

PREREQUISITES:

Good understanding of object concepts.

Sound knowledge of any object oriented language.

Knowledge of software engineering process.

Page 3: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 3/163

3

Course description:

TABLE OF CONTENTS:

Module1 Introduction

Module2 Use case diagram

Module3 Flow of events

Module 4 Realization of the class diagram

Sequence diagram and Collaboration Diagram

Module5 Class diagram and refinement attributes

Module6 State transition and activity diagram

Module7 Implementation diagram

Component diagram and Deployment diagram

Module8 Understanding project culture

Appendix-A

Page 4: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 4/163

4

Module-1

Page 5: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 5/163

5

Importance of modeling

What is a model?

 – A model is a simplification of reality

Why do we model? – help visualizing

 –  permit specification

 –  provides a template – document decisions

Page 6: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 6/163

6

4 Principles of Modeling

Choose your models well

Every model may be expressed at various

levels of precisionThe best models are connected to reality

 No single model is sufficient

Page 7: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 7/163

7

What is Software Engineering?

DEFINITION:The application of systematic, disciplined andqualifiable approach to the development, operation and maintenanceof a software system is software engineering.

Software development life cycle has following stages:

REQUIREMENT

ANALYSIS

DESIGN

IMPLEMENTATION

TESTING

Page 8: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 8/163

8

Effort Distribution for each stage:

Analysis & design 40 %

Development 20 %

Testing 40 %

Analysis - What is to be done ?

Design - How it is to be done ?

Two Popular methodology approaches are:

Structured Analysis & Design

Object Oriented Analysis & Design-OO model

Page 9: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 9/163

9

Major benefits of OOAD:

The object oriented approach is a way of thinking about a problem using

real world concepts instead using adhoc function concepts.

We intent to learn OOAD approach for the following reason:

 – Promotes better understanding of user requirements – Leads cleaner design

 – Design flexibility'

 – Decomposition of the system is consistent

 – Facilitates data abstraction & information hiding

 – Software reuse – Easy maintenance

 – Implementation flexibility

Page 10: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 10/163

10

Elements of OO Methodology:

Following are three elements for every OO methodology:

 Notation

Process / Method

Tool

Page 11: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 11/163

11

What is Notation?

Notation:

It is collection of graphical symbols for expressing model of the

system.

The Unified Modeling Language [UML] provides a very robust setof notation which grows from analysis to design.

This brings end of the method wars as far as notation is concerned

with adoption of the language [UML]

By unifying the notations used by these object oriented methods, the unifiedmodeling language provides the basis for a de facto standard in the domain of 

object oriented analysis and design founded on a wide base of user 

experience

Page 12: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 12/163

12

What is UML?

It is a Unified Modeling Language, which is mainly a collection of graphicalnotation that methods use to express the designs.

The UML is language for visualizing, specifying, constructing and documentingthe artifacts of software system.

UML is visual modeling language for modeling systems and is non proprietary

UML is not a radical departure from Booch, OMT, OOSE notations but rather legitimate successor to all three.

It is an evolutionary step, which is more expressive and more uniform thanindividual notations.

Whitehead says

“ By relieving the brain of unnecessary work, a good notation, sets it free toconcentrate on more advance and creative problems “ UML is not a method or  process but is the means to express the same.

Page 13: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 13/163

13

Where can you use the UML?

System of several different kinds, absolutely anywhere everywhere.

Primarily for software intensive systems like:

Systems software

Business processes

Page 14: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 14/163

14

The Evolution of the UML:

UML1.1

UML1.0

UML0.9

Beta version OOPSLA’96

Public Feedback 

Submission of OMG group

OMG vote’97

Submission to OMG, sept’97

Unified Method 0.8

Other method Booch OMT OOSE

Page 15: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 15/163

15

Advantages of UML:

Captures business processes

Enhance communication and ensures the right communication

Capability to capture the logical software architecture independent of the implementation language

Manages the complexity

Enables reuse of design

Page 16: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 16/163

16

UML refers to:

UML things:

Class, component, node, relationship, package etc..

UML diagrams:Use case diagram, interaction diagram, class diagram, State

diagram,deployment diagram

Page 17: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 17/163

17

What is Process?

What is Process?

It is an extensive set of guidelines that address the technical and

organizational aspects of software development focusing on requirements,

analysis and design.

Process basically encapsulates the activities leading to the orderlyconstruction of system model.

OO model supports the iterative and incremental model for the process.

Page 18: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 18/163

18

More about Process?

Guidance as to the order of team’s activities

It specifies what artifacts should be developed

It directs the task of individual developers and team as a whole

It offers criteria for monitoring and measuring project activities

The selection of particular process will vary greatly depending uponthings like problem domain, implementation technology and skills of team

Booch,OMT,OOSE and many other methods have well defined processand UML supports almost all methods

There has been some convergence on development process practices butthere is no consensus for standardization.

Framework for the every stage of software development life cycle.

Page 19: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 19/163

19

Best Practices followed by Rational Unified Process

Develop software iteratively

Manage requirements

Use component based architectures Visually model software

Verify S/W quality

Control changes to software.

Page 20: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 20/163

20

What is a tool?

It is automated support for every stage of software development

life cycle.

Since we are concentrating on requirement, analysis and design phase,

following are the names of few tools which are greatly in use:

1. Rational Rose

2. Cayenne

3. Platinum

4. Select

Page 21: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 21/163

21

Why Tool?

Helps designer for creating designs much more quickly.

Supports validations like:

Consistency checking 

Completeness checking 

Constrain checking.

Time required for certain operation could be predicted .

Code generation

Reverse engineering.

Round trip engineering Conversion from SSAD to OOAD

Quick documentation…etc

Page 22: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 22/163

22

Triangle for Success:

All three components play equally important role towards the success

of the project.

 Notation

MethodTool

Page 23: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 23/163

23

Objective of the first module:

Get introduced with Unified Modeling Language and know the basic

components of software development life cycle.

Page 24: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 24/163

24

Module-2

Page 25: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 25/163

25

OO model:

STATIC MODEL

DYNAMIC MODEL

PHYSICAL MODEL

LOGICAL MODEL

The models of Object Oriented Development

Page 26: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 26/163

26

Models and Views:

4+1 view of OO model.

 –  Process view

 –  Deployment view

 –  Logical view

 –  Dynamic view+

 –  Use case view

As shown in the model , for each dimension we define a number of diagrams

that denote a view of the system’s model. The use case view is central since its contents drive the developments of 

other views.

Page 27: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 27/163

27

UML diagrams:

1. Use case diagram

2. Class Diagram

3. Behavioral diagrams

- State chart diagrams- Object diagram

- Activity diagrams

- Interaction diagrams

- Sequence diagrams

- Collaboration diagrams

4. Implementation diagrams- Component diagram

- Deployment diagram

Page 28: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 28/163

28

Semantics of Diagrams:

· Use case diagrams represent the functions of a system from the user’s point of view.

· Sequence diagrams are a temporal representation of objects and their 

interactions.· Collaboration diagrams are a spatial representation of objects, links,

and interactions.

· Object diagrams represent objects and their relationships, andcorrespond to simplified collaboration diagrams that do not represent

message broadcasts.· Class diagrams represent the static structure in terms of classes and

relationships.

Page 29: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 29/163

29

Semantics of Diagrams:

Contd...

· State chart diagrams represent the behavior of a class in terms of states

· Activity diagrams are to represent the parallel behavior of an operationas a set of actions.

· Component diagrams represent the logical components of anapplication.

· Deployment diagrams represent the deployment of components on particular pieces of hardware.

Page 30: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 30/163

30

What is USE CASE diagram?

A use case diagram establish the capability of the system as a whole.

Components of use case diagram:

Actor 

Use case

System boundary

Relationship

Actor relationship

Semantic of the components is followed.

Page 31: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 31/163

31

ACTOR:

What is an actor?

An actor is some one or something that must interact with the system

under development

UML notation for actor is stickman, shown below.

Customer  Manager  Cashier 

Page 32: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 32/163

32

ACTOR:

More about an actor:

It is role a user plays with respect to system.

Actors are not part of the system they represent anyone or anything that must interact with the system.

Actors carry out use cases and a single actor may perform more

than one use cases.

Actors are determined by observing the direct uses of the

system,

Page 33: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 33/163

33

ACTOR:

Contd…

Those are responsible for its use and maintain as well as other systems

that interact with the developed system.

An actor may

- input information to the system.

- receive information from the system.

- input to and out from the system.

Page 34: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 34/163

34

ACTOR:

How do we find the actor?

Ask following questions to find the actors:

 –  Who uses the system?

 –  Who installs the system? –  Who Starts up the system?

 –  What other systems use this system?

 –  Who gets the information from the system?

 –  Who provides information to the system?

Actor is always external to the system. They are never part of thesystem to be developed.

Page 35: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 35/163

35

ACTOR:

4-Categories of an actor:

Principle : Who uses the main system functions. Secondary : Who takes care of administration & maintenance.

External h/w : The h/w devices which are part of application

domain and must be used.

Other system: The other system with which the system must

interact.

Page 36: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 36/163

36

ACTOR:

Note:

If newly identified actor is using a system in a same way like an

existing actor, then new actor can be dropped. If two actors use system in the same way they are same actors.

Page 37: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 37/163

37

USE CASE:

What is USE case?

A use case is a pattern of behavior, the system exhibits

Each use case is a sequence of related transactions performed by an

actor and the system in dialogue.

USE CASE is dialogue between an actor and the system.

Examples:

Open new account Withdrawal of cash

from ATM

Page 38: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 38/163

38

USE CASE:

More about USE CASE:

It is a snapshot of one aspect of system.

They model a dialog between actor and system.

A use case typically represents a major piece of functionality that

is complete from beginning to end.

Most of the use cases are generated in initial phase, but you find

some more as you proceed.

A use case may be small or large. It captures a broad view of aprimary functionality of the system in a manner that can be easily

grasped by non technical user.

Page 39: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 39/163

39

USE CASE:

Contd…

A use case must deliver something of value to an actor.

The use cases may be decomposed into other use cases. Use cases also present a good vehicle for project planning.

Page 40: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 40/163

40

USE CASE:

How do we find the use cases?

What functions will the actor want from the system?

Does the system store information? What actors will create, read,update. Or delete that information?

Does the system need to notify an actor about changes in its internal

state?

Page 41: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 41/163

41

USE CASE:

Generic format for documenting the use case:

  - Pre condition: If any

 – Use case : Name of the case.

 – Actors : List of actors(external agents), indicating who

initiates the use case. – Purpose : Intention of the use case.

 – Overview : Description.

 – Type : primary / secondary.

 – Post condition: If any

Typical Course of Events:ACTOR ACTION : Numbered actions of the actor.

SYSTEM RESPONSE : Numbered description of system responses.

Page 42: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 42/163

42

USE CASE:

USE CASE documentation example:

The following use case describes the process of opening a new account in

the bank. 

Use case :Open new account

Actors :Customer, Cashier, Manager 

Purpose :Like to have new saving account.

Description :A customer arrives in the bank to open the new

account. Customer requests for the new account

form, fill the same and submits, along with the

minimal deposit. At the end of complete successfulprocess customer receives the passbook.

Type:Primary use case.

Page 43: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 43/163

43

Grouping USE CASES:

Those use case functionality which are directly dependent on the

system environment are placed in interface objects

Those functionality dealing with storage and handling of information

are placed in entity objects

Functionality's specific to one or few use cases and not naturally

 placed in any of the other objects are placed in control objects

By performing this division we obtain a structure which helps us to

understand the system from logical view

Page 44: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 44/163

44

OOAD --- USE CASE driven

Capture,clarify

& validate use cases

Analysis Design &

Implementation

Implementuse cases

Use cases make up the glue

Test

Verify that use cases

are satisfied

Page 45: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 45/163

45

SYSTEM BOUNDARY:

What is System Boundary?

It is shown as a rectangle.

It helps to identify what is external verses internal, and what the

responsibilities of the system are.

The external environment is represented only by actors.

Page 46: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 46/163

46

RELATIONSHIP:

What is Relationship?

Relationship between use case and actor.

Communicates

Relationship between two use cases

Extends

Uses

 Notation used to show the relationships:

<< >>

Page 47: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 47/163

47

RELATIONSHIP:

Relationship between use case and actor is often referred as

“communicates” .

Relationship between two use cases is refereed as either uses

or extends.

USES: 

- Multiple use cases share a piece of same functionality.

- This functionality is placed in a separate use case rather thandocumenting in every use case that needs it.

Page 48: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 48/163

48

RELATIONSHIP:

Contd...

A uses relationship shows behavior that is common to one or 

more use cases.

EXTENDS:

It is used to show optional behavior, which is required only

under certain condition.

Page 49: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 49/163

49

USE CASE diagram:

Use case diagram for the shown functionality.

Balance status

report

Withdraw cash

Validation

uses

CustomerClerk 

Manager

extends

ATM

Page 50: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 50/163

50

Objective of the second module

To understand and capture the detailed specification of a system to be

developed, from user perspective.

Page 51: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 51/163

51

Module-3

Page 52: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 52/163

52

Beginning Analysis and Design

Completion of first version of use case diagram initiates the processes

of analysis and design.

UML provides the framework to carry out the process of analysis and

design in form of set of diagrams.

Every diagram and notation used in the diagram carries the semantics.

First step towards analysis and design is to specify the flow of events.

Page 53: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 53/163

53

Flow of Events:

A flow of events document is created for each use case.

Details about what the system must provide to the actor when the use isexecuted.

Typical contents

 –  How the use case starts and ends –   Normal flow of events

 –  Alternate flow of events

 –  Exceptional flow of events

Typical Course of Events has:

Actor Action(AA)

System Response(SR)

Page 54: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 54/163

54

 Normal Flow of Events: 

For withdrawal of cash:

1.(SR) The ATM asks the user to insert a card.

2.(AA) The user inserts a cash card.

3.(SR) The ATM accepts the card and reads its serial number.

4.(SR) The ATM requests the password.

5.(AA) The user enters 1234.

6.(SR) The ATM verifies the serial number and password with the

 bank and gets the notification accordingly.

7.(SA)The ATM asks the user to select the kind of transaction.

8.(AA)User selects the withdrawal.

Page 55: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 55/163

55

 Normal Flow of Events: 

Contd...

9.(SR)The ATM asks for the amount of cash; user enters Rs. 2500/-

10.(SR)The ATM verifies that the amount of cash is within predefined

 policy limits and asks the bank, to process the transaction which

eventually confirms success and returns the new account balance.

11.(SR) The ATM dispenses cash and asks the user to take it.

12.(AA) The user takes the cash.

13.(SR) The ATM asks whether the user wants to continue.

14.(AA) The user indicates no.

Page 56: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 56/163

56

 Normal Flow of Events:

Contd...

15.(SR) The ATM prints a receipt, ejects the card and asks the user to

take them

16.(AA) The user takes the receipt and the card.

17.(SR) The ATM asks a user to insert a card.

Page 57: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 57/163

57

Alternative Flow of Events:

For withdrawal of cash use case:

9. The ATM asks for the amount of cash; the user has change of mind

and hits the “cancel”.

Page 58: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 58/163

58

Exceptional Flow of Events:

For withdrawal of cash use case:

3 Suspicious pattern of usage on the card.

10 The machine is out of cash.

11 Money gets stuck in the machine.

Page 59: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 59/163

59

Why flow of events?

It helps in understanding the functionality of a system to be developed.

Flow of events helps in finding objects of the system to be developed.

Happens to be most important and very first step towards analysis and

design.

Page 60: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 60/163

60

What is Scenario?

The functionality of the use case is captured in flow of the

events.

A scenarios is one path through the flow of events for the use

case.

Scenarios are developed to help identify objects, classes and

object interactions for that use case.

Page 61: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 61/163

61

Objective of the third module

To understand the flow of each functionality and find out the objects

and methods required to build the system.

Page 62: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 62/163

62

Module-4

Page 63: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 63/163

63

USE CASE Realizations:

The use case diagram presents an outside view of the system

Interaction diagrams describe how use cases are realized as

interactions among societies of objects.

Two types of interaction diagrams

 –  Sequence diagrams

 –  Collaboration diagrams

Page 64: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 64/163

64

What is Interaction diagram?

Interaction diagrams are models that describe how groups of objects

collaborate in some behavior 

There are 2 kinds of interaction diagrams

• Sequence diagram

• Collaboration diagram

Sequence diagrams are a temporal representation of objects and their 

interactions

Collaboration diagrams are spatial representation of objects, links and

interrelations

Page 65: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 65/163

65

What is sequence diagram?

Typically these diagrams capture behaviors of the single

scenario.

Shows object interaction arranged in time sequence.

They show sequence of messages among the objects.

It has two dimensions, vertical represents time & horizontal

represents objects.

Components of sequence diagram:

-objects

-object lifeline

-Message

-pre/post conditions.

Page 66: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 66/163

66

OBJECT & OBJECT LIFE LINE:

Object are represented by rectangles and name of the objects are

underlined.

Object life line are denoted as dashed lines. They are used to

model the existence of objects over time.

 Name:Class

Page 67: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 67/163

67

MESSAGES:

They are used to model the content of communication between objects.

They are used to convey information between objects and enable objects

to request services of other objects.

The message instance has a sender, receiver, and possibly other 

information according to the characteristics of the request.

Messages are denoted as labeled horizontal arrows between life lines.

The sender will send the message and receiver will receive the message.

Page 68: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 68/163

68

MESSAGES:

Contd…

May have square brackets containing a guard conditions. This is a Boolean

condition that must be satisfied to enable the message to be sent.

May have have an asterisk followed by square brackets containing an iteration

specification. This specifies the number of times the message is sent.

May have return list consisting of a comma -separated list of names that designate

the values of returned by the operation.

Must have a name or identifier string that represents the message.

May have parentheses containing an argument list consisting of a comma separated

list of actual parameters passed to a method.

Page 69: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 69/163

69

:Customer  :ATM :Bank  

Request password

Verify accountEnter the password

Account o.k.Request option

Enter option

Request amount

Enter the amountUpdate transaction

Transaction commit

Insert card

Dispense cash

Request take cash

Take cash

Request continuation

Terminate

Print receipt ,eject card

Request take cardTake card

Display main screen and prompt for the card.

:Transaction

Create

Transaction

Transaction

complete

Sequence diagram [for withdrawal of cash, normal flow]

Page 70: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 70/163

70

What is Collaboration diagram?

Collaboration diagrams illustrate the interaction between the objects,

using static spatial structure.

Unlike sequence diagram the time is not explicitly represented in these

diagrams

In collaboration diagram the sequence of messages is indicated bynumbering the messages. The UML uses the decimal numbering

scheme.

In these diagrams, an actor can be displayed in order to represent the

triggering of interaction by an element external to the system.

This helps in representing the interaction, without going into the

details of user interface.

Page 71: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 71/163

71

Components of collaboration diagram:

 Named objects

Links: Links are represented by a continuous line between objects, and

indicates the exchange of messages.

Messages has following attributes:

• Synchronization --thread name, step within thread.

• Sequence number 

• Message labels : The name of the message often corresponds to an operation

defined in the class of the object that is the destination of the message.

Message names may have the arguments and return values.

• *[iteration].

• It uses decimal notation.

• Message direction.

Page 72: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 72/163

72

Semantics of components:

Object names identify which objects are participating and the links

show which objects collaborate

A link between two objects must exist for one object to send message

to another and vice a versa. Messages in the collaboration diagram get transformed to more

detailed signature.

They use the decimal notation system for numbering the messages.

The direction of the message defines the sender and receiver of 

the message

Page 73: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 73/163

73

The elements of message:

Predecessor 

Role names

Message qualifiers

 –  Iteration expression

 –  Parameters –  Return values

 –  Guard

 –  Message stereotypes

Concurrent thread sequencing

Thread dependencies

Message expression

[Pre] A1:*(expression):doIt(p,r):return value

Page 74: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 74/163

74

The examples of message:

4:Display(x,y) Simple

message

3.3.1:Display(x,y) Nested

message

4.2:subtract[Today,Birthday]:age Nested

message with

return value

[Age >=18] 6.2:Vote() Conditional

message

4.a,b.6/c.1:Turnon(Lamp) Synchro. with

other flow of 

execution

1*:wash() Iteration

3.a,3.b/4*||[i:=1..n]:Turnoff() Paralleliteration

Page 75: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 75/163

75

Collaboration diagram [for withdrawal of cash, normal flow.]

1. Insert card

Enter password, Enter kind

Enter amount,

Take cash, Take card

cancel,Terminate, Continue

Display main screenunreadable card message,

request password,

request kind, request amount,

canceled message, eject card, failure message,

dispense cash, request take cash

request continuation,

 print receipt, request take card

 bad account message,

 bad bank account messageVerify account,

 process transaction

Transaction succeed

Transaction failed

account o.k.

 bad account, bad password,

 bad bank code

Create Transaction

Transaction completeCUST-

OMER 

BANK 

ATM

TRANSA-

CTION

Page 76: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 76/163

76

Objective of the fifth module

To know the interaction among the objects in temporal and spatial

form.

To know how objects collaborate among each other and hence

delegate the responsibility to the respective objects.

To understand how the messages get matured with more information.

Page 77: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 77/163

77

Module-5

Page 78: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 78/163

78

What is Class diagram?

A class diagram shows the existence of classes and their relationshipsin the logical view of a system

UML modeling elements in class diagrams are: –  Classes, their structure and behavior.

 –  relationships components among the classes like association,aggregation, composition, dependency and inheritance

 –  Multiplicity and navigation indicators –  Role names or labels.

Page 79: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 79/163

79

Major Types of classes:

Concrete classes

A concrete class is a class that is instantiable; that is it can have different

instances.

Only concrete classes may be leaf classes in the inheritance tree.

Abstract classes An abstract class is a class that has no direct instance but whose descendants

classes have direct instances.

An abstract class can define the protocol for an operation without supplying a

corresponding method we call this as an abstract operation.

An abstract operation defines the form of operation, for which each concrete

subclass should provide its own implementation.

Page 80: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 80/163

80

RELATIONSHIP:

Association

Aggregation

Composition

Inheritance

Dependency

Instantiation

Page 81: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 81/163

81

ASSOCIATION:

These are the most general type of relationship:

It denotes a semantic connection between two classes

It shows BI directional connection between two classes

It is a weak coupling as associated classes remain somewhat

independent of each other 

Example:

CUSTOMER ATM system

Page 82: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 82/163

82

AGGREGATION:

This is a special type of association

The association with label “contains” or “is part of” is an

aggregation

It represents “has a “ relationship

It is used when one object logically or physically contains other 

The container is called as aggregate

It has a diamond at its end

The components of aggregate can be shared with others It expresses a whole - part relationships

Page 83: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 83/163

83

AGGREGATION:

Example:

Customer  ATM card

Page 84: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 84/163

84

COMPOSITION:

This is a strong form of aggregation

It expresses the stronger coupling between the classes

The owner is explicitly responsible for creation and deletion of 

the part

Any deletion of whole is considered to cascade its part

The aggregate has a filled diamond at its end

Window Client Area

Page 85: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 85/163

85

INHERITANCE:

The inheritance relationship helps in managing the complexity by

ordering objects within trees of classes with increasing levels of 

abstraction. Notation used is solid line with arrowhead,shown below.

Generalization and specialization are points of view that are based on

inheritance hierarchies.Account

SavingAccountCurrentAccount

Page 86: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 86/163

86

DEPENDENCY:

Dependency is semantic connection between dependent and

independent model elements.

This association is unidirectional and is shown with dotted

arrowhead line.

In the following example it shows the dependency relationshipbetween client and server.

The client avails services provided by server so it should have

semantic knowledge of server.

The server need not know about client.

Client Server  

Page 87: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 87/163

87

INSTANTIATION

This relationship is defined between parameterized class and

actual class.

Parameterized class is also referred as generic class.

A parameterized class can’t have instances unless we first

instantiated itExample:

Queue<int>

Queue

Element

Page 88: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 88/163

88

What is Cardinality? :

Definition: Number of instances of each class involved in the dialogue is

specified by cardinality.

Common multiplicity values:

Symbol Meaning

1 One and only one

0..1 Zero or one

M…N From M to N (natural integer)

0..* From zero to any positive integer 

1..* From one to any positive integer 

Also thought can be given about navigability to every applicable relationship.

Page 89: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 89/163

89

Reaching the class diagram:

In collaboration diagram we have shown the objects, their interaction and

detailed message signature.

This information is carried forward to the class diagram.

At this point,we group the similar objects and form classes.

Messages get mapped to responsibilities for respective classes. Find the attributes for every class.

Transform the links to appropriate relationships.

Relationship is further refined with respect to multiplicity and navigability.

This complete procedure brings the minimal class diagram [for withdraw cash use

case, normal flow.]

Page 90: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 90/163

90

Class diagram [for withdrawal of cash, normal flow]

Customer 

Transaction

1

0..*

1

0..*ATMSystem

1..*

1..*

1..*

1..*

Bank[Branch]1

1..*

1

1..*1

11

1

Page 91: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 91/163

91

What more to the Class Diagram?

Till this slide we have worked out the essentials of class diagram for 

withdrawal of cash use case, normal flow of events.

Similar exercise required to be carried out for every scenario and clubbed all

in the class diagram.

At this point, we refine this integrated class diagram to add further finedetails. Approximate sketch for this class diagram has been shown at the end

of this module.

Refinement attributes should be updated right from sequence diagram to

class diagram.

 Next few slides will take into the discussion of refinement attributes.

This process of iterative and incremental development will continue till there

is no change in two consecutive iteration.

Page 92: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 92/163

92

OOAD---Iterative & Incremental Approach

Identify objects

Identify Messages

Group Objects

into classes

Identify & classify

Class relationshipsIdentify class

behavior

Group classes

into domains

Validate Classes

& Objects

Page 93: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 93/163

93

Refinement attributes:

Stereotypes:

Stereotypes are part of the range of extensibility mechanism provided

 by UML

It permits user to add new model element classes on top of the kernel

 predefined by UML

Page 94: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 94/163

94

Refinement attributes:

Contd…

Constraints:

Constraints are functional relationship between the entities and object

model. The entities include objects, classes, attributes, association,

links. A constraint restricts the values that entities can assume.

UML doesn't specify a particular syntax for constraints, other than

they should appear between braces, so they may therefore be

expressed using natural language, pseudo code, navigation expression

or mathematical expression

UML1.2 does prefer the use of a constraint language OCL i.e. Object

Constraint Language, which is subset of UML.

Page 95: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 95/163

95

Refinement attributes:

Transaction

Window

length/width

{No. of transaction <=5 /day}

{0.8<=length/width <= 1.5}

Constraint on the same class.

A constraint between the

 properties of the same object

 No window will have an aspect ratio i.e. (length/width) of less than 0.8 or > 1.5

Number of withdrawal transaction should be less than five per day.Example:Constraints

Page 96: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 96/163

96

Refinement attributes:

Qualifier:

UML provides a role of constraint notation to indicate different kind

of collections that may be inherent in the analysis model

Common role constraints for multi valued roles include

{ordered} Collection is maintained in sorted manner 

{bag} Collection may have multiple copies of same item.

{set} Collection may have at most one copy of given item.

Some constraints may be combined such as: {ordered set}

Page 97: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 97/163

97

Refinement attributes:

Qualifier:

Another common design scheme is to use a key value to retrieve an

item from the collection. This is called as qualified association and the

key value as qualifier.

A qualified association is the UML equivalent of a programmingconcept variously known as associative arrays, maps,dictionaries

A qualified association relates two object classes and a qualifier 

The qualifier is a special attribute that reduced the effective

multiplicity of an association.

One to many and many to many association may be qualified.

Page 98: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 98/163

98

Refinement attributes:

Check for many to many relationship, if any, normalize with qualifier 

or association class.

Check for the scope forming abstract classes and template classes.

Check for helper functions.

Thought can be given for using the design patterns.

Page 99: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 99/163

99

Objective of the fifth module:

Learn to build the architecture, which contains the entire information

of the system to be developed.

It is this architecture which is called as BLUE PRINT is handed over 

for coding.

Page 100: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 100/163

100

Refined Class diagram [for withdrawal of cash] 

SavingAccount

AccountAccessor 

<<abstract>>

TellerScreen

ATMScreenBankAssociates

CashierStation

person<<abstract>>

Cash

BatchJob

NoteHelpForBankCard

ATMSystem

BankComputer 

Area

BankCard

Bank[Branch]11

1..*1..*

Customer 

1

0..1

1

0..1

11

Account<<abstract>>

1

1

1

1

1..*

1

1..*

1

Transaction

11..*

11..*

Slips

CurrentAccount

Few more relationship can be further added to the shown diagram:

Page 101: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 101/163

101

Module-6

Page 102: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 102/163

102

What is state transition diagram?

A state transition diagram shows the states of a single object, the

events or the messages that cause a transition from one state to another 

and the action that result from a state change.

A state transition diagram will not be created for every class in the

system.  Components of State Diagram:

 –  Start State

 –  Stop state

 –  State Transition

Page 103: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 103/163

103

Semantics of every components:

State: A state is a condition during the life of an object when it satisfies

some condition, performs some action, or waits for an event.

The UML notation for a state is a rectangle with rounded corners.

Special states:There are two special states.Start state: Each state diagram must have one and only one start

state. Notation for start state is “filled solid circle”.

Stop State: An object can have multiple stop states. Notation for stop

state is bull’s eye.

S ti f t

Page 104: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 104/163

104

Semantics of every components:

Contd...

State transition: A state transition represents a change from an

originating to a successor state.

Transition label: event name[guard condition] / action

State Transition Diagram

Page 105: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 105/163

105

State Transition Diagram [for Account class. ]

Operational

Dormant

Open

seized

transaction request[ validate ] / update()

close

no transaction / Transfer_to_Dormant_Ledger 

fill_the_request_form / update()

Fraud or authorized instruction[Validate]

/ lockAccount()

matter_resolved[ validate ] / unlockAccount()

request and fill the form for new saving account[ validate ] / process

fill_the_request_form/update(

)

transactionStrart / Transfer_to_main_ledger ()

 Note:Account can be closed from open state as well 

Page 106: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 106/163

106

More about State Diagram:

A state diagram will not be created for every class.

state diagrams are used only for those classes that exhibit interesting

 behavior.

State diagrams are also useful to investigate the behavior of user 

interface and control classes. State diagram are used to show dynamics of a individual class

h i i i di ?

Page 107: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 107/163

107

What is activity diagram?

It is a special kind of state diagram and is worked out at use case level.

These are mainly targeted towards representing internal behavior of a a

use case.

These may be thought as a kind of flowchart.

Flowcharts are normally limited to sequential process; activity diagramscan handle parallel process.

Activity diagrams are recommended in the following situations:

Analyzing use case

Dealing with multithreaded application

Understanding workflow across many use cases.

Consistency Checking

Page 108: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 108/163

108

  Consistency Checking

Consistency checking is the process of ensuring that,information in both static view of the system(class diagram)and the dynamic view of the system(sequence andcollaboration diagram) is telling the same story.

Obj i f h i h d l

Page 109: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 109/163

109

Objective of the sixth module

Understand the dynamic behavior of a class

Way to find the parallel processes at use case level. 

Page 110: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 110/163

110

Module-7

Wh i di ?

Page 111: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 111/163

111

What is component diagram?

COMPONENT DIAGRAM:

Component diagrams illustrate the organizations and dependencies

among software components.

A component may be

• A source code component

• A run time components

• An executable component

• Dependency relationship.

Component Diagram

Page 112: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 112/163

112

Component Diagram [for withdrawal of cash]

policy.dll

BranchBank.dllcustomer.dll

ATM.exe

BranchBank.exe

BankServer.exe

Wh t i d l t di ?

Page 113: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 113/163

113

What is deployment diagram?

A deployment diagram shows the relationship among software and hardware

components in the delivered system.

These diagram include nodes and connections between nodes.

Each node in deployment diagram represents some kind of computational unit, in most

cases a piece of hardware.

Connection among nodes show the communication path over which the system willinteract.

The connections may represent direct hardware coupling line RS-232 cable, Ethernet

connection, they also may represent indirect coupling such as satellite to ground

communication.

D l t di

Page 114: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 114/163

114

Deployment diagram

ATM_ machine

Bank_ server 

BranchBank_ 

EthernetEthernet

Bank.exe

BankServer.exeATM.exe

Obj ti f th th d l

Page 115: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 115/163

115

Objective of the seventh module:

To understand the organization of software modules and their 

deployment on the respective hardware.

Page 116: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 116/163

116

Module-8

 

Understanding the project culture

Page 117: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 117/163

117

Understanding the project culture

It may be:

1.Calendar Centric

2.Requirement Centric

3.Documentation Centric

4.Quality Centric

5.Architecture Centric

U d t di th j t’ lt

Page 118: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 118/163

118

Understanding the project’s culture

Architecture driven projects represent the most mature style of development.

These projects are characterized by a focus on creating a frame work that satisfies all

known requirement, yet is resilient enough to adapt to those requirements, that are not yet

known or well understood.

In every sense of the word, architect-driven policies are in evolutionary step beyond

requirement driven policies.

Architecture driven style of development is usually the best approach for the creation of most

complex software intensive systems

Understanding the project’s culture

Page 119: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 119/163

119

Understanding the project s culture

Architecture driven style of development typically observe thefollowing process:

1. Specify the system’s desired behavior through a collection of 

scenarios. (Analysis)2. Create, then validate, an architecture. (Design)

3. Evolve that architecture, making mid-course corrections as

necessary to adopt to new requirements as they are uncovered.

OOAD Architecture Centric

Page 120: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 120/163

120

OOAD---Architecture Centric

What exactly is nature of the well structured object oriented

architecture??

1. A set of classes, typically organized into multiple hierarchies.

2. A set of collaboration that specify how those classes co-operate

to provide various system function.

ESSENCE OF OOAD AND UML

Page 121: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 121/163

121

ESSENCE OF OOAD AND UML

 Use case driven

Architecture centricIncremental and iterative approach.

Desire for good Architecture

Page 122: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 122/163

122

g

Those of us who have been trained as architects have this desire

  perhaps at the very center of our lives,that one day, some where

somehow, we shall build one building which is wonderful, beautiful,

  breathtaking, a place where people can walk and dream for centuries.

CHRISTOPHER ALEXANDER

Same desire should also be applicable in creating software architecture aswell  .

Page 123: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 123/163

123

Basic Structural Modeling

Object-Oriented Programming

Aline Yurik 

Classes and Types

Page 124: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 124/163

124

Classes and Types

Class is a user-defined type

They can be used as built-in types

Objects are variables

Objects can contain other objects

Two Views of a Class

Page 125: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 125/163

125

Two Views of a Class

Interface (outside view)

 –  specification of operations

 –  hides structure and

implementation

Implementation (inside

view)

 –  state information

 –  all details –  can change without

affecting interface

customer LName

FName

Address

IDGetName( )

GetAddress( )

customer 

Database pointer 

ID

GetName( )

GetAddress( )

Multiple Implementations

Page 126: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 126/163

126

Multiple Implementations

A single interface mayhave multiple

implementations

Implementations can be

changed withoutchanging interfaces

Implementations can be

improved without

affecting rest of system

Examples:Complex Numbers

 –  Cartesian coordinates

 –  Polar coordinates

Set Representation –  array

 –  linked list

 –  hash table

Sort Algorithms

 –  insertion sort

 –  quick sort

Polymorphism

Page 127: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 127/163

127

Polymorphism

Instances of classes

with superclasses are

 polymorphic

They have more thanone type

Person

Employee

Manager 

Chris

Polymorphic Operations

Page 128: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 128/163

128

Polymorphic Operations

Operations defined for 

arguments of a class type

also accept arguments of 

subclass type

Operation marry(Person)

 –  expects an arguments of 

type Person

 –  also accepts Employee or 

Manager 

Person

Employee

Manager 

Class Modeling Notation

Page 129: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 129/163

129

Class Modeling Notation

Person

name: string

age: integer 

Class with Attributes:

(Person)

Joe Smith

24

(Person)

Mary Sharp

52

Objects with Values:

change-job

change-address

Class Modeling Notation cont

Page 130: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 130/163

130

Class Modeling Notation - cont.

Class-Name

attribute-name-1: data-type-1 = default-value-1

attribute-name-2: data-type-2 = default-value-2

operation-name-1(argument-list-1): result-type-1

operation-name-2(argument-list-2): result-type-2

Class Relationships

Page 131: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 131/163

131

Class Relationships

Relationships are connections between classes

Dependencies

 – one class uses another 

Generalizations

 – connect generalized classes to more specialized ones

Associations

 – structural relationships among instances

Example: Relationships

Page 132: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 132/163

132

Example: Relationships

Window

open()

close()

move()

display()

handleEvent()

ConsoleWindow DialogBox Control

Event

Generalization Generalization

Dependency

Association

Dependency

Page 133: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 133/163

133

Dependency

“Using” relationship

Change in one class may effect another 

One class may use another as an argument in an

operation

FilmClip

name

playOn(c : Channel)start()

stop()

reset()

Channel

Generalization

Page 134: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 134/163

134

Generalization

Relationship between ageneral class and a more

specific class

General class:

 –  super-class, parent

Specific class:

 –  subclass, child

is-a relationship

 –  is-a-kind-of 

Child inherits properties of  parents

Child may inherit some or all attributes and

operations of parents

Child may have its own

attributes and functions Single parent - single

inheritance

More than one parent -

multiple inheritance

Example: Generalization

Page 135: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 135/163

135

Example: Generalization

Shape

origin

move()resize()display()

Rectangle

corner : Point

Circle

radius : Float

Polygon

points : List

display()

Square

Is-a Relationships

Page 136: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 136/163

136

Superclasses and SubclassesClasses are related via

is-a relationships

 –  employee is-a person

 –  manager is-a employee –  car is-a vehicle

 –  truck is-a vehicle

Superclasses (base classes)

 –  more general classes

 –  Person is a superclass of 

Employee

Subclasses (derived

classes)

 –  more specialized classes

 –  Manager is a subclass of 

Employee

Example: Superclasses and

Page 137: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 137/163

137

Subclasses

Person

Employee Student

Manager 

Inheritance (is-a relationship)

Page 138: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 138/163

138

Inheritance (is a relationship)

Bank account balance

holder 

account #

list of deposits

list of withdrawals

deposit(amt)withdraw(amt)

 balance?

transactions?

savings account

 post_interest(int_rate)

overload:

transactions?

checking accountlist of checks

Check(num, amt)

overload:

transactions?Int-checking account

interest earned

Inheritance - cont

Page 139: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 139/163

139

Inheritance cont.

Classes inherit data and operations of their 

superclasses

Inheritance allows software to be organized

the way people think 

 –  people organize things hierarchically

 – generalization and specialization are common

ways to manage complexity

Inheritance leads to software reuse

Inheritance of Specification vs.

Page 140: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 140/163

140

Inheritance of Implementation Sometimes inherited

operations need to be

redefined

Inheritance of specification

 –  idea behind the field

 –  mandatory inheritance

 –  leads to reuse of design

Inheritance of 

implementation

 –  sometimes desirable

 –  sometimes needs to beredefined for 

correctness or 

efficiency

Association

Page 141: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 141/163

141

Association

Structural relationship

How objects are connected to each other 

Binary association

 –  between two classes

Unary association

 – within the same class

 N-ary association

 – multiple classes

Association Attributes

Page 142: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 142/163

142

Association Attributes

 Name and direction

 –  e.g., works for 

Role

 –  what role each class plays

Person CompanyWorks for 

Person Company

+employer +employee

Association Attributes - cont.

Page 143: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 143/163

143

Association Attributes cont.

Multiplicity

 –  how many object are involved on each side of the

association

Aggregation

 –  whole/part relationship

Person Company*1..*

+employer +employee

*1..*

Department

Company

1

*

1

*

Aggregation: a-part-of 

R l i hi

Page 144: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 144/163

144

Relationship

document paragraph sentence

microcomputer

monitor system box mouse keyboard

chassis CPU RAM fan

1 * 1 *

1

* 0..1

* 0..1

Aggregation and Generalization

Page 145: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 145/163

145

Aggregation and Generalization

Aggregation

 –  several components

make up an aggregate

 –  a-part-of relationshipGeneralization

 –  superclasses and

subclasses

 –  is-a relationship

lamp

base shade switch

lamp

fluorescent

lamp

incadescent

lamp

Abstract vs. Concrete Class

Page 146: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 146/163

146

Abstract vs. Concrete Class

Abstract class

 –  has no direct instances

 –  subclasses have direct

instances –  logical superclass

Concrete class

 –  has direct instances

employee

year-to-date earnings

compute pay {abstract}

hourly employee

hourly rate

overtime pay

compute pay

salaried employee

weekly rate

compute pay

Modeling Simple Dependencies

Page 147: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 147/163

147

ode g S p e epe de c es

Connection between a class and another 

class, used as a parameter in an operation

CourseSchedule

add(c : Course)

remove(c : Course)

Course

Iterator 

<<friend>>

Modeling Single Inheritance

Page 148: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 148/163

148

g g

Put common attributes and operations in thegeneral class Security

presentValue()

history()

CashAccount

interestRate

presentValue()

Stock

presentValue()

Bond

presentValue()

Property

assessments

presentValue()

SmallCapStock LargeCapStock

Modeling Structural

R l ti hi

Page 149: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 149/163

149

Relationships

School

Student

1..*

*

1..*

*

member 

Course

** **

attendsInstructor 

* 1..** 1..*

teaches

Department

1 1..*1 1..*

Has

1..*

1..*

1..*

1..*

0..1

0..1

0..1

+chairperson0..1

1..*

1..*

assignedTo

1..*

1..*

Multiple Inheritance

Page 150: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 150/163

150

p

Class can inherit features from more than

one superclass

Feature from the same ancestor found among

multiple paths is inherited once

Any ambiguities should be resolved in

implementations

 – need to explicitely spell out which feature to use

Example: Multiple Inheritance

Page 151: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 151/163

151

p p

vehicle

land vehicle water vehicle

car amphibious vehicle boat

Example: Multiple Inheritance

Page 152: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 152/163

152

p p

Brand X

Products

Brand Y

ProductsComputers

Brand X

Computers

Brand Y

Computers

Brand X

Mainframes

Brand X

PCs

Brand YMinicomputers

Structural Diagrams

Page 153: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 153/163

153

g

Class Diagram

 – shows classes, interfaces, collaborations and their 

relationships

Object Diagram – shows objects and their relationships

Component Diagram

 – shows components and their relationships

Deployment Diagram

 – shows nodes and their relationships

Diagrams

Page 154: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 154/163

154

g

Structural Diagrams:

Class diagrams

Object diagrams

Component diagrams

Deployment diagrams

Behavioral Diagrams:

Use case diagrams

Sequence diagrams

Collaboration

diagrams

State chart diagrams

Class Diagrams

Page 155: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 155/163

155

g

Contents:

Classes

Interfaces

Collaborations Relationships

 –  dependency

 –  generalization

 –  association

Common Uses:

Model vocabulary of a

system

Model simplecollaborations

Model logical

database schema

Example: Class Diagram

Page 156: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 156/163

156

p gCompany

Headquarters

Office

address : String

voice : Number 

Department

name : Name

** **

Location

0..1

*

0..1

*

Person

name : Name

employeeID : Integer 

title : String

getPhoto(p : Photo)

getSoundBite()

getContactInfo()

getPersonalRecords()

1..*

*

1

*

+member  1..*

*

+manager 1

*

ContactInfo

address : String

PersonnelRecord

taxID

employmentHistory

salaryISecureInfo

Modeling Simple Collaborations

Page 157: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 157/163

157

g p

Collaboration: –  class works together with

others to carry out bahavior 

Identify function or 

 behavior to model

Identify classes, interfaces

that participate in

collaboration

Use scenarios

CollisionSensor 

PathAgent*1 *1

SteeringMotor MainMotor 

Driver 1

1

1

1

1 11 1

Motor 

move(d : Di rect ion, s : Speed)

stop()

resetCounter()

status() : Status

distance() : Integer 

-- seek path

-- avoid obstacles

Modeling a Logical Database

Schema

Page 158: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 158/163

158

SchemaClass diagrams are a superset of entity relationship

diagrams used for DB modeling

Identify classes representing DB data as persistent

Avoid cyclic, 1-to-1 and N-ary associations – create intermediate classes to simplify structure

Move business rules to a layer of classes separate

from persistent classes

Example: Modeling a Schema

Page 159: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 159/163

159

p g

School

name : Name

address : String

phone : Number 

addStudent()

removeStudent()

getStudent()getAllStudents()

addDepartment()

removeDepartment()

getDepartment()

getAllDepartments()

<<persistent>>

Student

name : Name

studentID : Number 

<<persistent>>

*

1..*

*

1..*

Member 

Course

name : Name

courseID : Number 

<<persistent>>

** **

 Attends

Instructor 

name : Name

<<persistent>>

1..*

*

1..*

*

Teaches

Department

name : Name

addInstructor()

removeInstructor()getInstructor()

getAllInst ructors()

<<persistent>>

1 1..*1 1..*

Has

1..*

1..*

1..*

1..*

1..*

1..*

1..*

1..*

 AssignedTo

0..1

0..1

0..1

+chairperson0..1

Page 160: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 160/163

160

Appendix-A

Strong recommendation

Page 161: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 161/163

161

Object Technology

 –  David A. Taylor 

Object Oriented Analysis and design with Applications

 – Grady Booch

UML distilled

 – Martin Fowler  Instant UML

 – Pierre - Alain Muller  Software Engineering

 – Roger S Pressman

REFERENCES

Page 162: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 162/163

162

Contd...Object Oriented Modeling and Design

 – James Rumbaugh

Object Oriented Software Engineering

 – Ivar Jacobson

Clouds to code

 – Jesse Liberty

Applying use cases

 – Geri Schneider 

 – Jason p. Winters

UML Toolkit

 – Hans-Eriksson and Magnus Penker 

Version1.1

Page 163: 26252990 UML Complete

8/9/2019 26252990 UML Complete

http://slidepdf.com/reader/full/26252990-uml-complete 163/163

THANK-U!