tcs2411 software engineering1 object-oriented analysis and design methods “how to create and...

48
TCS2411 Software Engineering 1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

Post on 21-Dec-2015

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 1

Object-Oriented Analysis and Design Methods

“How to create and define objects?”

Page 2: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 2

Lecture Objectives

To understand the process of identifying and creating objects for a system

To describe a method for developing objects for an object-oriented system

To describe the representations that can be used for objects and their relationships

To discuss the dynamic aspects of object-oriented systems and how to model them

Page 3: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 3

Too Many Methodologies!Booch Object-Oriented DesignRumbaugh Object Modeling TechniqueShlaer and Mellor Analysis and DesignJacobson ObjectoryWirfs-Brock Responsibility Driven DesignMartin and Odell Object-Oriented

Analysis and DesignOthers…..

Page 4: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 4

Object-Oriented Analysis

Identify the objects and classesIdentify the object attributesIdentify operations on objects and

classesDefine object and class relationshipsModel dynamic concepts

Page 5: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 5

Identify the objects and classes

Grammatical Analysis Nouns are objects and attributes Verbs are operations or services

Tangible entities (things), roles, events, interactions, etc. in application domain

Use behavioural approach Participants in behaviours as objects

Scenario-based analysis

Page 6: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 6

Identify the object attributes

Specify attributes (instance variables) of objects in problem domain

These are to be recorded, displayed, stored, and/or manipulated in functions of the domain

Page 7: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 7

Identify operations on objects and classes

Operations that are used to interact with the objects and classes

Each class has a protocol that captures the messages or operations that could be handled by the class or its instances

Users or “clients” of classes and objects deal primarily with the external operations of the class

Page 8: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 8

Example Scenario

“The Office Information Retrieval System (OIRS) can file documents under some name in one or more indexes, retrieve documents, display and maintain document indexes, archive documents and destroy documents. The system is activated by a request from the user and always returns a message to the user indicating the success or failure of the request.”

Page 9: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 9

Objects Identified

Index

Name

DisplayDelete entryAdd entry

User

Get commandPut message

Document

Name

File Retrieve Archive Destroy

RetrievalSystem

User command

Page 10: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 10

Define object and class relationships

Capture relationship between classes. Typical relationships:

Inheritance Organisation of classes or entity types in

problem domainOne-to-One, One-to-Many, Many-to-

Many relationships that exist between objects

that reference each other

Page 11: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 11

Example of Inheritance

Person

StudentEmployee

MarketingPersonSalesPerson

SalesManager

Page 12: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 12

Example of Other Relationships

Country City

PersonCompany

File User

Has-capital

Works-for

Accessible-by

One-to-One

One-to-Many

Many-to-Many

Page 13: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 13

Model dynamic concepts

State transition diagrams Specify states of the objects Specify events that trigger transitions Specify actions taken due to transitions

Data flow diagrams Describe flow of objects and information

Timing diagrams Illustrate object interactions over time

Page 14: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 14

State transition diagram

Black’sturn

White’sturn

Start

Blackmoves

Whitemoves

checkmate

checkmate

stalemate

stalemate

Draw

Whitewins

Blackwins

Page 15: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 15

Data flow diagram

Customer

Update

Verify

Account

password

amount

cash

Codedpassword

oldbalance

Passwordok

newbalance

Page 16: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 16

Timing diagrams

Caller Phone line CalleeCaller lifts receiver

Dial tone begins

Dials number

Ringing tone Phone rings

Answers phone

Tone stops Ringing stops

Phones connected Phones connected

Callee hangs up

Connection broken Connection broken

Page 17: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 17

Unified Modeling Language Approach OOA

User view model – system represented from the user’s perspective by developing

use-case modelStructural view model – data and

function is view from inside the system, static structure (classes, objects, relationships) is modeled

Page 18: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 18

Use CaseScenario based technique for

requirement elicitationUse case should achieve the following

objectives : Define functional and operational

requirements of the system Provide clear description of how end user

and the system will interact with one another

Basis for validation testing

Page 19: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 19

Use Case Diagram Elements

Actor : Entities that interact with the system Person, machine, another

system etc Represent roles that a

user play in the system Use case

Sequence of transaction performed by the system

Initiated by an actor to invoke certain function in the system

Sensor

Customer Credit System

Borrow book Input password

Page 20: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 20

Use Case Diagram For The Library

Borrow copy of book

Reserve book

Extend loan

Return copy of bookBookBorrower

Extend loan

Return copy of book

JournalBorrower

Update catalog

Librarian

Browse

Browser

Page 21: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 21

Identify Objects and Classes

Object Thing that can interact

with Reacts when send

messages concept, abstraction or

thing that has sharp boundaries and meaning for an application

Object has State : value of property

at a given time Behavior : objects action

and reaction Identity : distinguishes

from other objects

Object Thing that can interact

with Reacts when send

messages concept, abstraction or

thing that has sharp boundaries and meaning for an application

Object has State : value of property

at a given time Behavior : objects action

and reaction Identity : distinguishes

from other objects

Class A sets of objects with an

equivalent roles in the system

Every object belongs to a class

Example : Tangible : book, copy,

course Roles : library member,

student Events : arrival, leaving,

request Interaction : meeting,

intersection

Class A sets of objects with an

equivalent roles in the system

Every object belongs to a class

Example : Tangible : book, copy,

course Roles : library member,

student Events : arrival, leaving,

request Interaction : meeting,

intersection

Page 22: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 22

Identify Class Attributes & Operations

Book

ISBNNo : StringTitle : StringAuthor : StringStatus : String

select()isAvailable()updateStatus()

Attributes

Operations

Characteristic of a class

Simple noun or noun phrases Must be unique

within class Value that the

property may hold in objects of that class

What the class can do / What the class should do

Operations are used to interact with objects and classes

Operation signature Optional argument

list Return class

Class Name

Page 23: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 23

RelationshipWhy do we need Relationship

All system encompass many classes and objects

Objects contribute to the behavior of a system by collaborating with one anotherCollaboration is accomplish through

relationships

Two important type of relationship during analysisAssociationAggregation

Page 24: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 24

Association

Represent relationship between objects of classes

Multiplicity Association Number of instance of one class related to one

instance of the other class Multiplicity indicator

Many - *Exactly one - 1Zero or more - 0 .. *One or more - 1 .. *Zero or one - 0 .. 1Specified range - m .. n Eg :- 2 .. 4

Page 25: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 25

Inheritance

Hierarchy abstraction where subclass inherits from one or more superclass

Subclass inherits attributes, operations and relationships

Subclass may have additional attributes, operations or relationship

How to find inheritance? Look for common behavior and

attributes in classes

Page 26: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 26

Aggregation

Known as part-of relationshipA whole class related to its partsAssociation or Aggregation ?

If two object tightly bound by a whole part relationship : Aggregation

If two object considered independent even though they are often linked : Association

Page 27: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 27

Example of Aggregation

ATM Panel Card Reader ATM Card

Country States1 1

Country and States are tightly coupled. States cannot function on its own if it taken away from country.

1 1 1 0 ..1

Card reader is part of ATM panel.

Page 28: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 28

Object Interactions

To show dynamic behavior of the system

Also known as Sequence DiagramInteraction between objects is

modeled using interaction diagram. Show how messages passed between

objects Realize use cases

Page 29: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 29

Object Interactions(Continued)

aMember:BookBorrower

theLibraryMember:LibraryMember

theCopy:Copy theBook:Book

borrow(theCopy)

1: okToBorrow

2: borrow

2.1: borrowed

Page 30: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 30

Changes In System : State Diagram

State of book object may change when a copy of book is successfully bookborrowable not borrowableThere is a copy available in the library

All copies are out on loan or reserved

not borrowable borrowable

returned()

borrowed()[not last copy]

returned()

borrowed()[last copy]

State diagram for class Book

Page 31: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 31

Deliverables from Unified Modeling Language Approach OOA

Use Case DiagramSequence DiagramClass DiagramState Transition Diagram

Page 32: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 32

Object-Oriented DesignDetailed specifications of the following:Subsystems or class categories

Partitioning the system, providing interfaces, interactions, and mapping to targeted system

Class definitions structure or representation behaviour or operations implementation algorithms additional support classes for

implementation

Page 33: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 33

Object-Oriented Design (Continued)

Class relationships Containment Referencing Aggregation Inheritance

Object diagrams and object relationships Descriptions of how objects interact Class interaction - what classes are used by

another class

Page 34: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 34

Object-Oriented Design (Continued)

State transition Extends state transition diagrams in

analysisTiming diagrams

Extends timing diagrams in analysisDesigning algorithms

implementation algorithms and logicPhysical compilation units

Compilation modules, interface specifications

Page 35: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 35

UML Approach to OOD

Object Oriented DesignObject Oriented Design

System DesignSystem Design Object DesignObject Design

Software Architecture

Software Architecture

Object Description

Object Description

ObjectInteraction

ObjectInteraction

Page 36: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 36

System Design

Partition the Analysis Model Refine analysis objects using inheritance, pattern and

encapsulation Package into subsystem or modules

Can be characterized by responsibility Design artifact may include

Refined class diagramInteraction, activity component & deployment

diagramState models

Composed classes into packages. Composition can be done base on

Use casesUnit of physical realizationProcessing

Page 37: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 37

System Design (continued)

Concurrency and Subsystem Allocation Assign concurrency if classes are active at the

same timeImplement on the same processor hardware

Concurrent is defined by examining the state diagram

Establish thread for active objectThread control continues when it sends message to

another object and wait for responses

Isolate these thread controls Consider performance, cost and overhead by

processor when allocates the object to the processor

Page 38: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 38

System Design (Continued)

Task Management Component How the task initiated Common

Event driven• Interrupt from outside source (Processor, sensor etc)

Clock driven• Interrupt from system clock

Determine the task priority and criticality High priority task must have immediate access

to the resources High critical task must operate continually

even if resources availability is reduced or system operates in degrade state.

Page 39: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 39

System Design (continued)

User Interface Component Define system menu and sub functions available

for the menuData Management Component

Data management for critical applicationLayered design

Creation of infrastructure for storage and retrievalUse database, files, shared memory

Design the attribute and operation to manage data

Resource Management Component Subsystem may compete to use the same

resources at the same time

Page 40: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 40

System Design (continued)

User Interface Component Define system menu and sub functions available

for the menuData Management Component

Data management for critical applicationLayered design

Creation of infrastructure for storage and retrievalUse database, files, shared memory

Design the attribute and operation to manage data

Resource Management Component Subsystem may compete to use the same

resources at the same time

Page 41: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 41

Activity DiagramActivity diagram

Activities coordination To show how an operation can be

implemented Useful when an operation has to

achieve a number of different thingsRecord dependencies between

activities Which thing can happen in parallel What must finished first before

something else can start

Page 42: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 42

Find book on shelf

Wait in queue

Record returnPut book back

on shelf

Record borrowing

Prepare for next member

[borrower]

[returner]

[returning]

[borrowing]

member librarian

Activity Diagram

Page 43: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 43

Object DesignObject Description

Establish object interfaceDefine message the object can receiveOperation the object can perform when it receives

the message

Implementation detailsObjects private partsInternal details about data structureDetails about the operation

Algorithms and Data Structure Algorithm created to implements operation

specification

Page 44: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 44

Component ModelComponent

Standard building unit that is used to develop an application

Types of component Source code (e.g: file containing code of the

class)Has to be available when compiled

Binary object code (e.g: class library)Depends on any object codeMust be linked to form an executable program

Executable application (e.g: the client/server, database manager)

May depend on other executable programs to interact at runtime

Page 45: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 45

A component diagram showing compile time dependencies

streams.o<<library>>

MyIO

MyApp<<executable>>

<<compile>>

<<link>>

component

dependency

Page 46: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 46

Deployment Model Deployment diagram shows

Physical communication links between hardware itemsMachines, printers and other resources

Relationship between physical machines and processesWhat runs where

shillay:Workstation

OXO:GameEngine

P1:PlayerInterface

craro:PC

P2:PlayerInterface

<<LAN>>

Node•Processor, capable of running the software component•Device that provides service

association

Page 47: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 47

Deliverables from UML Approach to OOD

Class Diagram (Refined)State Transition Diagram (Refined)Component DiagramDeployment Diagram

Page 48: TCS2411 Software Engineering1 Object-Oriented Analysis and Design Methods “How to create and define objects?”

TCS2411 Software Engineering 48

References

“Software Engineering: A Practitioner’s Approach” 5th Ed. by Roger S. Pressman, Mc-Graw-Hill, 2001

“Object-Oriented Modeling and Design” by James Rumbaugh et al, Prentice Hall, 1991

“Object Orientation” by Setrag Khoshafian & Razmik Abnous, John Wiley & Sons, 1995

“Teach Your Self UML in 24 hours” by Joseph Schmuller, Sams Publication, 2001

“Mastering UML with Rational Rose” by Wendy Boggs and Michael Boggs, Sybex Inc, 2000

“Using UML Software Engineering With Objects and Components” by Perdita Stevens, Rob Pooley, Addison Wesley, 2000