82
F ALL 2010 FA ST National University of Computer and Emerging Sciences Islamabad, Pakistan OBJECT ORIENTED ANAL YSIS AND DESIGN Instructor : Dr . Arshad Ali Shahid : Muhammad Ahmed Lecture : 02 Date : 11 th August, 2010 1

02-Introduction to OOAD

Embed Size (px)

Citation preview

Page 1: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 1/82

FALL 2010

FAST National University of Computer and Emerging Sciences Islamabad, Pakistan 

OBJECT ORIENTEDANALYSIS AND DESIGN

Instructor : Dr. Arshad AliShahid : Muhammad Ahmed

Lecture : 02

Date : 11th August, 2010

1

Page 2: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 2/82

OOADFall 2010

FAST National University of Computer and Emerging Sciences Islamabad, Pakistan 

INTRODUCTION TOOBJECT ORIENTED

ANALYSIS ANDDESIGN

Session 1

Page 3: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 3/82

3

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Session Objectives and LearningOutcomes:

What is Object; What is Object-Orientation?

Why OO?

What is OOAD & How to do OOAD?

What are Object Oriented (OO) Methods?

(C++, Java, Oracle??)

What are OO methods used for?

What are the features of OO methods?

How are they different from SSADM?

3

Page 4: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 4/82

Software Crises

Software Complexity

Why Object-Oriented?4

Page 5: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 5/82

5

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Software Project Failure

1. Problems Faced By The Customers US Internal Revenue System has abandoned its tax system modernization

program after having spent $4 billion;

the state of California spent $1 billion on its non-functional welfare database

system; the £339 million UK air traffic control system was reported as being two years

behind schedule;

a discount stock brokerage company had 50 people working 14 hours or more aday to correct three months of records clerically – the report commented that

the new system had been rushed into operation without adequate testing; in the United Kingdom, a Home Office immigration service computerization

project was reported as having missed two deadlines and was nine months late;

the Public Accounts Committee of the House of Commons (UK) blamedsoftware bugs and management errors for £12 million of project costs in relationto an implementation of a Ministry of agriculture computer system to administer

farm subsidies.

5

Page 6: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 6/82

6

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Software Crises

2. General

H/W advances continue to outpace the pace ofbuilding S/W to tap hardware‘s potential.

Our ability to build S/W could not keep pace withthe growing need of business and market

Demand of highly reliable operations (ticketing,communication, traffic control and power control)of S/W due to our dependency on computer

6

Page 7: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 7/82

7

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Software Crises

3. AN INDUSTRY PERSPECTIVE

Why cost estimations are mostly incorrect?

Why requirements are kept changing

Why does it take so long to get programsfinished?

Why are costs so high?

Why can‘t we find all errors before we give theS/W to our customer?  

Why do we have difficulty in measuring progressas S/W is being developed?

7

Page 8: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 8/82

8

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

The statistics – Chaos Report

Standish Group – 1995

365 IT executives in US companies in diverse industry segments.

8,380 projects

Project completion

16%

31%

53%

On time, on budget,

with all of the specified

features and functions

Cancelled before they

were completed

delivered and

operational but over-

budget, over-schedule

or with fewer features

and functions thanaverage cost

overrun = 189%

average

timeoverrun

= 222%.

61% of originally specifiedfeatures included

 

 

?

In Averages•  189% of original budget

•  221% of original schedule

•  61% of original functionality

8

Page 9: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 9/82

9

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Symptom of Software Crisis

About US$250 billions spent per year in theUS on application development

Out of this, about US$140 billions wasted dueto the projects getting abandoned or reworked;this in turn because of not following best

practices and standards Ref: Standish Group, 1996

9

Page 10: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 10/82

10

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Symptom of SoftwareCrisis……. 

10% of client/server apps are abandoned orrestarted from scratch

20% of apps are significantly altered to avoiddisaster

40% of apps are delivered significantly late

Source: 3 year study of 70 large c/s apps 30 European firms.Compuware (12/95)

10

Page 11: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 11/82

11

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Observed Problems

Software products:

fail to meet user requirements

crash frequently

expensive

difficult to alter, debug, enhance

often delivered late

use resources non-optimally

11

Page 12: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 12/82

OOADFall 2010

FAST National University of Computer and Emerging Sciences Islamabad, Pakistan 

GO OBJECT-

ORIENTED – THESOLUTION

But Why Object Oriented!

Page 13: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 13/82

13

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Object Versus Function-Oriented AnalysisDesign 

13

Decomposition is the primary strategy to deal with the complexity of S/W project.

Functional decomposition is common in the structured analysis and design. System

can be functionally divided into sub-functions differently by different people.

That’s why it is more commonly called as Analysis & Design.

That’s why a functional hierarchy exists.

Object oriented decomposition has been mentioned in few (Larman) books but

Object identification or classification are most suitable terms used in the OOA. That’s why Object Modeling is more commonly used term as object’s are identified 

(they are already there) and modeled in a language rather defined by the analyst.

That’s why decomposition hierarchy does not exist but a collaboration between

objects.

Mp3Recorder

FmPlayer VideoPlayer

Mp3Player

Classification/Decompositionby Objects/concepts

OO A&D

Multimediasystem

Play mp3 Play fmRecord mp3

Decomposition by functions/processesStructured A&D

Page 14: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 14/82

14

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Why Object-Oriented?14

Page 15: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 15/82

15

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What kind of language can alleviate difficulties with communication & complexity hopefully well ? 

Why Object-Oriented?......

  ―The "software crises" came about when people realized the major problems in software development were … caused by communicationdifficulties and the management of complexity‖ [Budd] 

The Whorfian Hypothesis:

Human beings … are very much at the mercy of the particular languagewhich has become the medium of expression for their society … the 'realworld' is … built upon the language habits … We cut nature up, organizeit into concepts, and ascribe significances as we do, largely because weare parties to an agreement to organize it in this way … and is codified inthe patterns of our language.

  

15

Page 16: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 16/82

16

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Why Object-Oriented? – Consider Human Growth & ConceptFormation

Communication & complexity about the problem and the solution, allexpressed in terms of concepts in a language!

But then, What is CONCEPT? [Martin & Odell]

Consider Human Growth & Concept Formation

stage  concepts infant  the world is a buzzing confusion 

very youngage 

"blue" "sky― (individual concepts)"blue sky― (more complex concept)hypothesis: humans possess an innate capacity for perception 

getting older  -> increased meaning, precision, subtlety, ...

the sky is blue only on cloudless days; the sky is not really blueit only looks blue from our planet Earth because of atmospheric effectselaborate conceptual constructs 

Concept formation: from chaos to order! 

16

Page 17: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 17/82

17

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Why Object-Oriented?- concepts and objects

So, concepts are needed to bring order … into… apparent chaos ! But, What is CONCEPT? [Martin & Odell] [Novak, 1984, Cambridge University Press]

Does Hasham understand the concepts? Do you understand what Hasham understands? 

Agree or Disagree? 

Study of a first grade class When given a list of 

concepts (water, salt water,Oceans, Penguins,...),

Hasham constructed a concept diagram through which he understan ds his world and communicates meaning 

17

Page 18: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 18/82

What is software crisis ? whatare it causes ? explain themwith reasons..

Assignment #118

Font : Verdana, size: 122-3 pages..

Focus on quality content rather than size

Deadline 22nd August

―Google + Wiki + copy, paste Job done‖ = 0 marks

Page 19: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 19/82

19

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What kind of language can be used to create this concept diagram, or Hasham’s mental image?  

Why Object-Oriented?… for Conceptual … Modeling Reasons 

19

Water

Rivers Oceans

Fish

Penguins

Crocodiles

Fresh water

Salt waterhave

havehave

live in

have

have

Can be

Can be

Page 20: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 20/82

20

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What is a model and why?

A model is a simplification of reality. e.g., a miniature bridge for a real bridge to be built

A model is our simplification of our perception ofreality

A model is an abstraction of something for thepurpose of understanding, be it the problem or asolution. To understand why a software system is needed, what it

should do, and how it should do it.

To communicate our understanding of why, what and how.

To detect commonalities and differences in your

perception, my perception, his perception and her

20

Page 21: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 21/82

The Solution!

OBJECT ORIENTEDMODELLING

21

Page 22: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 22/82

22

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Object-Oriented Modeling

Attach the behavior and information that isimportant to objects 

Associate relations between object to describethe static and dynamic organisation andstructure of real situation

22

Page 23: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 23/82

23

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Object-Oriented Modeling

Tree Next-ToHouse

Lives-inHassan

Drives Car

23

FAST National Uni ersit of Comp ter and Emerging Sciences

Page 24: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 24/82

OOADFall 2010

FAST National University of Computer and Emerging Sciences Islamabad, Pakistan 

WHAT IS OBJECTORIENTATION?

Page 25: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 25/82

25

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What is an Object?25

A structure that has identity and properties and behavior

It is an instance of a collective concept, i.e., a class.

An "object" is anything to which a concept applies, in our awareness   Things drawn from the problem domain or solution space.

e.g., a living person in the problem domain, a software component in the solutionspace.

Page 26: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 26/82

26

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

An Object

Operations:

Work

Dance

Drive

Jump

Attributes:

Height

Eye colour

Hair colour

Weight

26

Page 27: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 27/82

27

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Relationships

Static :

relations existing over a long time

objects know about each other existence

Dynamic : relations which two objects communicate with

each other

object sending stimuli to other stimuli - events, messages

27

FAST National University of Computer and Emerging Sciences

Page 28: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 28/82

OOAD

Fall 2010

FAST National University of Computer and Emerging Sciences Islamabad, Pakistan 

PRINCIPLES OF

OBJECT ORIENTEDMODELLING

B i P i i l f Obj

Page 29: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 29/82

29

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Object Orientation

   E  n  c  a  p  s

  u   l  a   t   i  o  n

   A   b  s   t  r  a  c   t   i  o  n

   P  o   l  y  m  o

  r  p   h   i  s  m 

   I  n   h  e  r   i   t  a  n  c  e

Basic Principles of ObjectOrientation

29

Ab t ti d

Page 30: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 30/82

30

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Abstraction andEncapsulation Abstraction Focus on the essential Omits tremendous amount of details …Focus on what an object ―is and does‖ 

Encapsulation a.k.a. information hiding Objects encapsulate:   property    behavior as a collection of methods invoked by

messages   state as a collection of instance variables

30

Page 31: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 31/82

31

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Encapsulation

 A concept of ‗Self-containing‘ 

Information hiding

 ‗internal‘ structure is hidden from their surroundings 

Behavior and information is represented orimplemented internally

Functionality and behavior characterized by‘interfacing’ operations 

31

Page 32: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 32/82

32

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What is generalization? Forall x [Car(x) - > …]  

Another Example of Abstraction andEncapsulation

<<instanceOf>>

<<instanceOf>>

<<instanceOf>> Class CarAttributes

Model

Location #Wheels =4

Operations Start Accelerate

32

Page 33: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 33/82

33

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Class

What is CLASS ? a collection of objects that share common properties, attributes, behaviorand semantics, in general.

A collection of objects with the same data structure (attributes, statevariables) and behavior (function/operations) in the solution space.

Classification Grouping of common objects into a class

Instantiation. The act of creating an instance.

Class CarAttributes

Model Location #Wheels =4

Operations Start Accelerate

<<instanceOf>>

<<instanceOf>>

<<instanceOf>>

33

Page 34: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 34/82

34

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Class

A class represents a template for severalobjects and describes how these objectsoperate and structured internally 

Objects of the same class have the samedefinition both for their operations and theirinformation structure (what about contents ?)

Class contains implementation of objects

34

Page 35: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 35/82

35

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

a + b = 10

ClassCourse

PropertiesNameLocation

Days offeredCredit hoursStart timeEnd time

BehaviorAdd a studentDelete a student

Get course rosterDetermine if it is full

Sample Class35

Page 36: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 36/82

36

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Decreasingabstraction

Increasingabstraction Asset

RealEstat

Savings

BankAccount

Checking Stock

Security

Bond

Elements at the same level of the hierarchy should be at the same 

level of abstraction 

Levels of abstraction36

Page 37: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 37/82

37

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Instance

An instance is an object created from a class

A class describes the behavior and information

structure of an instance, while the current stateof the instance is defined by the operationsperformed on the instance

System‘s behavior is performed via theinteractions between instances

37

Page 38: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 38/82

38

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

multiple inheritance?

Person

name

NIC No

Student

std-id

level

Employee

emp-id

age

Inheritance

Specialization: The act of defining one class as a refinement ofanother (Generalized).

Subclass: A class defined in terms of a specialization of asuperclass using inheritance.

Superclass: A class serving as a base for inheritance in a class

hierarchy Inheritance: Automatic duplication of superclass attribute and

behavior definitions in subclass.

38

Page 39: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 39/82

39

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Why Inheritance?

Show similarities

Reuse common descriptions

‗Software Reuse‘ 

Easy modification of model by performingmodification in one place

Avoid redundancy, leading to smaller and

more efficient model, easier to understand

39

Page 40: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 40/82

40

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

The ability to hide many differentimplementations behind a single interface

Manufacturer AManufacturer B

Manufacturer C

What is Polymorphism?40

Page 41: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 41/82

41

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Objects of different classes respond to the same

message differently.

Polymorphism

 payTuition

Person

Name

NIC

Student

std-idlevel

Employee

emp-id

In-StateStudent

payTuition payTuition

Out-of-StateStudent

payTuition

41

Page 42: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 42/82

42

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Why Polymorphism

A very strong tool for allowing systemdesigners to develop flexible systems (e.g.shape)

Designer only need to specify what shall occurand not how it shall occur

To add an object, the modification will only

affect the new object, not those using it

42

Page 43: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 43/82

43

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Tube

Pyramid

Cube

Shape

DrawMoveScale

Rotate

<<interface>>

Realization relationship

What is an Interface?

Interfaces formalize polymorphism Interfaces support ―plug-and-play‖

architectures

43

Page 44: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 44/82

44

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

• Information hiding - all data should be hidden within a class, at least inprinciple.

• make all data attributes private

• provide public methods to get and set the data values ( We don‘tnecessarily need to have getter setters for variables relevant internally only)

• e.g. Access to the grade information should be done through public 

methods , such as setGrade and getGrade

 payTuition

setGrade()

getGrade()

Studentstd-idLevelgrade

Interfaces (Public)44

Abstract Class vs Concrete

Page 45: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 45/82

45

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Abstract Class vs. ConcreteClass

Abstract Class.

Which can not be instantiated

Because it has at-least one abstract method

(method which has no implementation) Concrete class.

Is a complete class. (what is a complete class ?)

Describes a concept completely.

Is intended to be instantiated.

45

Page 46: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 46/82

46

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

State of an Object

What is STATE ?State is defined by the current values of theattributes or properties

What is STATE CHANGE ? A "state change" is the transition of an objectfrom one state to another.

What is EVENT ?An "event" is a noteworthy change in state [Rumbaugh]

46

What is Object Oriented

Page 47: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 47/82

47

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What is Object-OrientedApplication?

Collection of discrete objects, interacting w. eachother Objects have property and behavior (causing state

transition) Interactions through message passing (eg func or method

calls) A sender object sends a request (message) to another

object (receiver) to invoke a method of the receiverobject‘s) 

Fn

Data

O1

Fn

Data

O2

Fn

Data

O3m1 m2{m in Fn} 

47

Page 48: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 48/82

48

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Is It Any Good?

A system which is designed and modelledusing an object-oriented technology is:

Easy to understand

Directly related to realityNatural partitioning of the problem

More flexible and resilient to change

Systems can be developed more rapidly and at alower cost

48

Page 49: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 49/82

49

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Limitations of SSADM

Treat data and function separately -function/dataoriented method

More difficult to maintain and re-configure

E.g Information hiding/data protection either global or local Modifications are unpredictable (because of no data

encapsulation)

Method require more abstraction - not too natural

Large semantic gap between external and internalview of a system

49

Page 50: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 50/82

50

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Some Qualities of OO

Easier maintenance. Objects may beunderstood as stand-alone entities.

Objects are potentially reusable components.

For some systems, there may be an obvious

mapping from real world entities to systemobjects

50

Page 51: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 51/82

OBJECT ORIENTEDMETHODS

51

Page 52: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 52/82

52

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Object-Oriented Methods

A technique for system modeling (not designing)

A technique to manage complexity inherent inanalysis, design, and implementation

For the analysis and design of system Provide integrated view of hardware and

software*

Provide a methodology for systemdevelopment

52

Page 53: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 53/82

53

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

OO Methods

Object Oriented Design (OOD) -Booch (1983), pioneeringbut not quite scalable

Object-Oriented System Analysis (OOSA) - Shlaer Shlaer& Mellor (1988), essentially information analysis based on

data analysis based on data modeling

Object-Oriented Analysis (OOA) -Coad & Yourdon (1991), amethod for developing OO system mode

Object Modeling Technique (OMT) - Rumbaugh et al.(1991), entity/relationship modeling with extension to modelclasses, inheritance and behavior

53

Page 54: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 54/82

54

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

OO Methods OO Methods.. (2)

Hierarchical Object-Oriented (HOOD) - ESA(1989), architectural design for Ada code.

Jacobson Use Case - Jacobson et al.(1992),

requirement (1992), requirement modeling,analysis, and design; also known as OOSE.

Unified Modeling Language (UML) – Booch,

Rumbaugh, Jacobson , (1997/2000), a methodthat provides a united OO approach to systemdevelopment

54

OO Methods - Some

Page 55: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 55/82

55

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

OO Methods - SomeAdvantages

Reduce semantic gap between domain (theactual) and model (the design)

Closer to reality e.g. classification of objects

close to how human understand surroundings Easier to understand and maintain

Easier to modify 

55

FAST National University of Computer and Emerging Sciences Islamabad Pakistan

Page 56: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 56/82

OOAD

Fall 2010

Islamabad, Pakistan 

OBJECT ORIENTED

ANALYSIS ANDDESIGN

Page 57: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 57/82

57

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What is OOAD?

• understanding, finding and describing concepts in the problem domain.

Analysis

• understanding and defining software solution/objects that represent the analysis concepts and will eventually be implemented in code.

Design

• Analysis is object-oriented and design is object-oriented. A softwaredevelopment approach that emphasizes a logical solution based onobjects.

OOAD

Traceability!

Involves both a notation and a process : Methodology  

57

Page 58: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 58/82

58

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What Is Analysis and Design?

Analysis emphasizes an investigation of the problem andrequirements, rather than a solution. "Analysis" is a broad term, best qualified, as in requirements

analysis (an investigation of the requirements) or object analysis(an investigation of the domain objects).

Design emphasizes a conceptual solution that fulfills therequirements, rather than its implementation. For example, a description of a database schema and software

objects.

Ultimately, designs can be implemented.

The term is best qualified, as an object design or databasedesign.

Analysis and Design have distinct activities (hence workproducts) but both can be performed iteratively.

58

What Is Object-Oriented Analysis and

Page 59: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 59/82

59

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

What Is Object-Oriented Analysis andDesign?

During object-oriented analysis, there is an emphasis on findingand describing the objects—or concepts—in the problem domain. For example, in the case of the library information system, some ofthe concepts include Book, Library, members, and librarian etc. 

During object-oriented design, there is an emphasis on definingsoftware objects and how they collaborate to fulfill therequirements. For example, in the library system, a Book softwareobject may have a title attribute and a getChapter method.

59

Page 60: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 60/82

60

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

An Example60

Object Oriented Analysis and

Page 61: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 61/82

61

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Analysis

Investigation of the problem

Design

Logical Solution

Construction

Code

DomainConcepts,Objects

Book

TitleAuthor

Print

DesignClass

Public class Book{

Private String title;public void print ();

}

OOLanguage

Code

Object Oriented Analysis andDesign

61

Object-Oriented Analysis &

Page 62: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 62/82

62

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Object Oriented Analysis &Design

1.

Findingobjects

2.

Organizingobjects

3.

Describinghow objects

interacts

4.

Defining theoperationsof objects

5.

Definingobjects

internally

62

O O

Page 63: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 63/82

63

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Organising Objects

ClassificationPartitioning- Similar objects- inheritance: ‗is a‘ 

Interactions/relationships between objects

AssociationComposition - structure object from parts

Aggregation - Whole/Part relationship: ‗has a‘ 

63

How to do OOAD

Page 64: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 64/82

64

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

How to do OOAD- notation vs. process

UML is a notation. So are English,

 Arabic,… 

Notation > How

Process > What and When (steps)

Wh U OO?

Page 65: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 65/82

65

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Requirements Analysis

Architectural Design

Detailed Design

Implementation

Release

Maintenance

 Q  u a l  i   t  yA  s  s  ur  an c  e

Software Lifecycle

Traceability!

Where to Use OO?65

E P i

Page 66: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 66/82

66

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Error Propagation

Traceability!

 Artificial problem??

 Accidental design

66

Specifications are important

Page 67: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 67/82

67

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Specifications are importanttoo!

67

Specifications are important too

Page 68: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 68/82

68

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Specifications are important too(2)!

68

Page 69: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 69/82

69

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

69

OOP VS OOAD

Page 70: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 70/82

70

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

OOP VS OOAD

Knowing an object-oriented language (suchas Java) is a necessary but insufficient firststep to create object systems

Knowing how to "think in objects" is alsocritical

OOAD, Emphasizes mastery of the fundamentals,such as how to assign responsibilities to objects,frequently used UML notation, and common

design pattern.

70

UML d OOAD

Page 71: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 71/82

71

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

UML and OOAD

The UML is a standard diagramming notation

As useful as it is to learn notation, there are more criticalobject-oriented things to learn; specifically, how to think inobjects—how to design object-oriented systems

The UML is not OOA/D or a method, it is simply notation*

Yet, one needs a language for OOA/D and "softwareblueprints," both as a tool of thought and as a form of

communication with others

Explore how to apply the UML in the service of doing OOA/D

71

Page 72: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 72/82

FAST National University of Computer and Emerging Sciences Islamabad, Pakistan 

Page 73: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 73/82

OOAD

Fall 2010

HOW TO DO OOAD ?

Hi t i l P ti

Page 74: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 74/82

74

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

OO Prog. Languages(Smalltalk, C++)

just program!

OO Design(Booch)

design thenprogram

OO Analysis(Rumbaugh, Jacobson)

Process Perspective OO Technology 

Analyze (use case) first,

then design,

then programWhere are we heading? 

Historical Perspective74

OO De elopment Processes

Page 75: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 75/82

75

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

OO Development Processes

FusionHewlett Packard

Recommended Process and Models

ObjectSpace best practices

Larman‘s experiences 

… 

The Rational Unified Process (RUP)Rational; Booch, Jacobson, and Rumbaugh

Some Popular OOAD Processes (for reference only) 

75

One Good Way: Use (OO) Design

Page 76: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 76/82

76

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

O e Good ay Use (OO) es gPatterns??

Reusable solutions to typical problems ―Each design pattern systematically names, explains, and

evaluates an important and recurring design in object-orientedsystems.‖ [Gamma] 

Name

• — identifies a particular pattern, creating a vocabulary.

Problem

• — identifies context when pattern should be applied.

Solution• — an abstract description of a design problem along with a

template object design that solves the problem.

Consequences

• — results and trade-offs of applying the pattern.

76

Who’s Behind Object-Orientation w. Diff.

Page 77: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 77/82

77

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

o s e d Object O e tat oConcerns?  

Knowledge Representation (inA.I.) 

•Psychological Validity

•Philosophical Validity

•Computational Validity

Databases •Emphasis in Persistent Data(and now ACID properties)

• RelationalDB

• Network DB

• Hierarchical DB

•OODB

ProgrammingLanguages •Emphasis in Efficiency

•Simula, SmallTalk, C++, Protel, Java

System/SoftwareEngineering 

ERDSDM

CM

ADT

ERD: Entity Relationship

Diagram

SDM: Semantic Data Model

ADT: Abstract Data Type

CM: Conceptual Model

Where does Unified Modeling Language come into this?

77

A New Paradigm with Evolving Object

Page 78: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 78/82

78

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

g g jOrientation

OOP: Object-Oriented Programming Simula (1967), Smalltalk (70‘s), C++ (mid 80‘s), Eiffel,

 Ada95, Turing, … 

OOD: Object-Oriented Design

Taxis (1976), Adaplex, …, Grady Booch (1980)  OOA: Object-Oriented Requirements RML (1981), James Rumbaugh (late 80‘s) 

OO-Databases (OODBs): 1980-90‘s 

OLE/DCOM, VisualBasic, CORBA, Java: mid 90‘s  .Net, C#, (eb/voice…/-)XML, J2EE: into 2000+ UML: mid 90‘s and still evolving 

78

Applying patterns and assigning

Page 79: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 79/82

79

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

pp y g p g gresponsibilities

How should responsibilities be allocated toclasses of objects?

How should objects interact?

What classes should do what? These are critical questions in the design of a

system.

Certain tried-and-true solutions to designproblems can be (and have been) expressed asbest-practice principles, heuristics, or patterns— named problem-solution formulas that codifyexemplary design principles.

79

Assigning Responsibilities

Page 80: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 80/82

80

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

Assigning Responsibilities

A critical, fundamental ability in OOA/D is to skillfullyassign responsibilities to software components

Why? …….. Because … 

it is one activity that must be performed— either whiledrawing a UML diagram or programming

it strongly influences the robustness, maintainability, andreusability of software components

Nine fundamental principles in object design andresponsibility assignment

Organized in a learning aid called the GRASP patterns.

80

Some Design Principles to

Page 81: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 81/82

81

Object Oriented Analysis & Design, Fall 2010 © Dr. Arshad Ali Shahid and Muhammad Ahmed 

g pconsider

Low Coupling 

low dependency between classes;

low impact in a class of changes in other

classes; high reuse potential;

High Cohesion

focused, manageable and understandable.High cohesion means that the responsibilitiesof a given element are strongly related andhighly focused.

81

Quiz No 2

Page 82: 02-Introduction to OOAD

8/4/2019 02-Introduction to OOAD

http://slidepdf.com/reader/full/02-introduction-to-ooad 82/82

Quiz No 2

Explain Inheritance andPolymorphism. How bothare related with each other.*

82