Top Banner
Object Oriented Analysis and Design
39

OOAD

Nov 14, 2014

Download

Documents

muchimp

ooad , fast nu , lahore , fakher , lodhi , object oriented analysis and design
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OOAD

Object Oriented Analysis and Design

Page 2: OOAD

The Role of Classes and Objects in Design

Identify the classes and objects that form the vocabulary of the problem domain (key abstractions)

Invent the structures whereby sets of objects work together to provide the behaviors that satisfy the requirements of the problem (mechanisms)

This view represents the logical framework of the system

Page 3: OOAD

Object Oriented Analysis

The intent of OOA is to define all classes, their relationships, and their behavior. A number of tasks must occur:

– Static Model (Object Model)a) Identify classes b) Specify class hierarchyc) Identify object-to-object relationshipsd) Model the object behavior

– Dynamic Model (Scenario Diagrams)

Page 4: OOAD

The UML Notation for Object Modeling

Operation:

Attribute:

Class

Operation1aOperation1b

Attribute1

Class1

Operation2

Attribute2aAttribute2b

Class2

Operation3a

Attribute3a

Class3

Operation4

Attribute4aAttribute4b

Class4

attribute name

Operation name

super class

class name

subclass name

AggregarionInheritance

Association

Multipicity ofassociation

1+

UML Object Model Notation

0..*

Page 5: OOAD

OOA and OOD – Abbot’s Textual Analysis

Part of speech Model com ponent Exam pleproper nounim proper noundoing verbbeing verbhaving verbadjectiveadjective phrase

instanceclass/ type/ roleoperationclassificationcom positionattribute value or classassociationoperation

Mehdi Hassanstudent, teacherbuyis a horse, is a bookfan has w ingsthis ball is greenthe custom er w ith childrenthe custom er w ho bought the kite

Page 6: OOAD

Derivation of the Object Model

• Select Objects - Who I am?• Define Attributes - What I

Know?• Show Collaborations - Who I

know?• Define Services - What I do?

Derived from Peter Coad

Page 7: OOAD

Select Objects

– Select actors - person, organization – Select Participants - role (agent, applicant, buyer,

etc)

– Select Places - airport, assembly-line, bank, city, etc

– Select Transactions - agreement, authorization, delivery, deposit, order, payment, sale

– Select Container Objects - bin, folder, shelf, etc

– Select Tangible things - account, book, calendar, cash box, cash drawer, item, plan, procedure, product, schedule, skill, tool, etc.

Page 8: OOAD

Identify Structures

• Identify Gen-Spec Structures (Hierarchy)• Identify Whole-Part structures

(Aggregations)

Page 9: OOAD

Define Object Attributes

• For actors consider name, address, phone.• for participants consider number, date and

time, password, authorization level.• for place/location consider number, name,

address (perhaps latitude, longitude, altitude).• for transaction consider number, date, time,

status.• for line item consider quantity, status.• for item consider name, description,

dimension, size, UPC, weight.

Page 10: OOAD

Show Collaborations

• For an actor, include an object connect to its participants (association).

• For a participant, include an object connection to its actor (already established) and its transactions (association).

• For a location, include object connections to objects that it can hold (association), to its part objects (aggregation), and to the transactions that are taking place at that location (association).

Page 11: OOAD

Show Collaborations - contd.

• For transactions, include object connections to its participants (already established), its line items (aggregation), and its immediate subsequent transaction (aggregation).

• For a transaction line item, include object connections to its transaction (already established), its item (association), a companion “item description” object (association), and a subsequent line item (association).

Page 12: OOAD

Show Collaborations - contd.

• For an item, include object connections to transaction line item (already established), a companion “item description” object (association).

• For a composite object, include object connections to its “part” object (aggregation).

• For all objects select connecting objects to which the object under consideration sends a message to get some information or to answer a query about objects directly related to it.

Page 13: OOAD

Define Services• Why does the system need this object any way? • What useful questions can it answer? • What useful action can it perform? • What this object can do, based upon what it knows?• What this object can do, based upon whom it

knows?• What calculations can it do?• What ongoing monitoring could it do?• What calculations across a collection could it make?• What selections across a collection could it make?

Page 14: OOAD

Define Services - contd.

• For an actor, consider: calculate for me, rate me, is <value>, rank participants, calculate over participants.

• For a participant, consider: calculate for me, rate me, is <value>, rank transactions, calculate over transactions.

• For a place, consider: calculate for me, rate me, is <value>, rank transactions, calculate over contents, calculate over container line items.

Page 15: OOAD

Define Services - contd.

• For a Transaction, consider: calculate for me, rate me, is <value>, how many, how much, rank transaction line items, rank subsequent transactions, calculate over transaction line items, calculate over subsequent transactions.

• For a line item, consider: calculate for me, rate me.

• For an item, consider: calculate for me, rate me, is <value>, how many, how much, rank, calculate over specific items.

Page 16: OOAD

CASE STUDY: A Convenience Store Point of Sale System

RequirementsR1. scan items and automatically price themR2. know whether an item is on saleR3. automatically total the sale and calculate taxR4. handle purchases and returnsR5. handle payments with cash, check, or chargeR6. authorize checks and cardsR7. calculate change when working with cash or checksR8. record all of the information about a customer

transactionR9. balance the cash in the drawer with the amount

recorded by the point-of-sale system.

Page 17: OOAD

CASE STUDY: A Convenience Store Point of Sale System

The point of sales system is needed to: to help each cashier work more effectively

during checkout, to keep good records of each sale, and to store more efficient store operations.

That is: to speed up checkout time to reduce the number of pricing errors to reduce the labour required to ticket the item

with a price, originally and when prices change.

Page 18: OOAD

System Features

• log important information• conduct business• analyze business results• interact with other systems

Page 19: OOAD

Features for Logging Important Information

to maintain prices based upon UPC to maintain tax categories (categories,

rates, and effective dates) to maintain the authorized cashiers to maintain what items we sell in a store to log the results of each sale in a store

Page 20: OOAD

Features for Conducting Business

to price each item, based upon its UPC to subtotal, calculate tax, and total to accept payment by cash, check, or

charge

Page 21: OOAD

Features for Analyzing Business Results

to count how many of each item sold to count how much we received in cash,

check, or credit card sales to assess how each cashier is

performing to assess how each store is performing

Page 22: OOAD

Features for Working With Interacting Systems

• to obtain authorization from one or more credit (or check) authorization system

Page 23: OOAD

System Features• Features for Logging Important Information

F1. to maintain prices based upon UPCF2. to maintain tax categories (categories, rates, and effective

dates)F3. to maintain the authorized cashiersF4. to maintain what items we sell in a storeF5. to log the results of each sale in a store• Features for Conducting Business

F6. to price each item, based upon its UPCF7. to subtotal, calculate tax, and totalF8. to accept payment by cash, check, or charge

• Features for Analyzing Business Results

F9. to count how many of each item soldF10. to count how much we received in cash, check, or credit card

salesF11. to assess how each cashier is performingF12. to assess how each store is performing

• Features for Working With Interacting Systems

F13. to obtain authorization from one or more credit (or check) authorization system

Page 24: OOAD

Select Objects

Select Actors person

Select Participantscashier, head cashier, customer

Select Places – Store, Shelf

Page 25: OOAD

Select Objects

• Select Transactions– sale, every sale is a collection of line

items, return, payments, session

• Select container classes– A store is a container class containing cashiers,

registers, items.

• Select Tangible Things– item, register, tax category, price

Page 26: OOAD

Identify Structures

• Identify Gen-Spec structures– kinds of stores– kinds of sales (sale, return)– kinds of payments (cash, check, and charge)– kinds of prices (regular, promotional (sale))

Page 27: OOAD

Gen-Spec Structures

Price

Promotional Price

Payment

ChargeCheque Cash Payment

Page 28: OOAD

Gen-Spec Structures

AuthorizedPayment

ChargeCheque Cash Payment

Payment

Page 29: OOAD

Identify Whole-Part Structures

A store as a whole is made up of cashiers, registers, and items.

A sale is constituted of sale line items.

Page 30: OOAD

Whole-Part Structures

Sale

Sales Line Item

Stote

Register ItemCashier

Page 31: OOAD

Establishing Responsibilities

Who I Know an actor knows about its participants

person knows about cashier

a transaction knows about its participantsa session knows about its register and cashier

A transaction contains its transaction line itemssale contains its sales line items

A transaction knows its sub transactionssession knows about its salessale knows about its payments

Page 32: OOAD

Who I Know - contd.

A place knows about its transactionsstore knows about its sessions

A place knows about its descriptive objectsstore knows about its tax categories

A container knows about its contentsa store knows about its cashiers, items, and

registers

Page 33: OOAD

Who I Know - contd.

Tax Category

Register

Store

SalesPayment

SessionCashier

Person

Page 34: OOAD

Object Model Diagram for the Point of Sales

System

Payment

ChargeCheque

Cash Payment

AuthorizedPayment

Sales Line Item

Return Line Item

Session

Store

RegisterCashier

Sale

Person

Item

Tax Category

UPCsPricePromotional Price

Page 35: OOAD

Object Oriented Design

Transformation of the analysis model into design model.

Analysis Model

Classes

attributes

methods

relationships

behavior

Design Model

Objects

data structures

algorithms

messaging

control

Translating the analysis model into a design model during object design

Page 36: OOAD

Object Oriented Programming

• OOP is simply implementing the OOD.

• Without OOD, OOP does not mean a lot.

Page 37: OOAD

Implementation of OOD in C++

• Classes - C++ Classes

• Messages - public methods

• Attributes - private variables/data structures

• Relationships– Hierarchy– Association– Aggregation

Page 38: OOAD

Implementing Relationships in C++

• Hierarchy - inheritance– Polymorphism - virtual methods (public or protected)

• Association– private variables of type pointer to the associated class.

– Concept of an object factory

• Aggregation – private variable (pointer or direct) of the type of the

aggregated class.

• Multiplicity of the relationship - standard containers (usually a list or a map)

Page 39: OOAD

Bibliography•Sommerville, Ian, Software Engineering, 5th Ed., Addison-Wesley, New York, 1995.•Pressman, Roger S., Software Engineering – A Practitioner’s Approach, 4th Ed., McGraw-Hill, 1997.•Booch, Grady, Object Oriented Analysis and Design, 2nd Ed., Benjamin/Cummings, Redwood City, CA, 1994.•Rumbaugh, J., Blaha, M., Premerlani, W., Eddy, F., and Lorensen, W., Object Oriented Modeling and Design, Prentice Hall, Englewood Cliffs, NJ, 1991.•Booch, G., and Rumbaugh, J., Unified Method for Object-Oriented Development, Rational Software Corp., 1996.•Coad, P., North, D., and Mayfield, M., Object Models - Strategies, Patterns, and Applications, Yourdon Press, Englewood Cliffs, NJ, 1995•Gamma, E. et al., Design Patterns, Addison-Wesley, 1995.•Jacobson, I., Object Oriented Software Engineering, Addison-Wesley, 1992.