+ All Categories
Home > Documents > Object oriented Programming Using...

Object oriented Programming Using...

Date post: 13-May-2018
Category:
Upload: votram
View: 217 times
Download: 3 times
Share this document with a friend
65
OO Analysis & Design Object oriented Programming Using C++ B.W.Gore 24 Feb 2016 B.W.Gore Object oriented Programming Using C++
Transcript

OO Analysis & Design

Object oriented Programming Using C++

B.W.Gore

24 Feb 2016

B.W.Gore Object oriented Programming Using C++

Object oriented Solution

I Decide on the approach (algorithm)

I Get a list of candidate classes

I Refine the list & finalize the classes needed to implementthe solution

I The classes are obtained by looking at the objects in theproblem domain

B.W.Gore Object oriented Programming Using C++

Object oriented Solution

I Decide on the approach (algorithm)

I Get a list of candidate classes

I Refine the list & finalize the classes needed to implementthe solution

I The classes are obtained by looking at the objects in theproblem domain

B.W.Gore Object oriented Programming Using C++

Object oriented Solution

I Decide on the approach (algorithm)

I Get a list of candidate classes

I Refine the list & finalize the classes needed to implementthe solution

I The classes are obtained by looking at the objects in theproblem domain

B.W.Gore Object oriented Programming Using C++

Object oriented Solution

I Decide on the approach (algorithm)

I Get a list of candidate classes

I Refine the list & finalize the classes needed to implementthe solution

I The classes are obtained by looking at the objects in theproblem domain

B.W.Gore Object oriented Programming Using C++

Classes

I The given problem domain has a number of objects

I These objects interact with each other in the predefinedmanner

I One way to decide on a set of classes would be:

1. what properties of them need to be captured in theprogram

2. to what objects do these properties naturally belong3. carefully designing classes based on this analysis

B.W.Gore Object oriented Programming Using C++

Classes

I The given problem domain has a number of objects

I These objects interact with each other in the predefinedmanner

I One way to decide on a set of classes would be:

1. what properties of them need to be captured in theprogram

2. to what objects do these properties naturally belong3. carefully designing classes based on this analysis

B.W.Gore Object oriented Programming Using C++

Classes

I The given problem domain has a number of objects

I These objects interact with each other in the predefinedmanner

I One way to decide on a set of classes would be:

1. what properties of them need to be captured in theprogram

2. to what objects do these properties naturally belong3. carefully designing classes based on this analysis

B.W.Gore Object oriented Programming Using C++

Classes

I The given problem domain has a number of objects

I These objects interact with each other in the predefinedmanner

I One way to decide on a set of classes would be:

1. what properties of them need to be captured in theprogram

2. to what objects do these properties naturally belong3. carefully designing classes based on this analysis

B.W.Gore Object oriented Programming Using C++

Classes

I The given problem domain has a number of objects

I These objects interact with each other in the predefinedmanner

I One way to decide on a set of classes would be:

1. what properties of them need to be captured in theprogram

2. to what objects do these properties naturally belong

3. carefully designing classes based on this analysis

B.W.Gore Object oriented Programming Using C++

Classes

I The given problem domain has a number of objects

I These objects interact with each other in the predefinedmanner

I One way to decide on a set of classes would be:

1. what properties of them need to be captured in theprogram

2. to what objects do these properties naturally belong3. carefully designing classes based on this analysis

B.W.Gore Object oriented Programming Using C++

Why design?

“Simply using an object oriented language (like C++)does not, in itself, guarantee miraculous results. Likeany other human endeavour software design is an art:discipline, hard work, inspiration, and sound technique,all play their parts”

- Rebecca Wirfs-Brock

B.W.Gore Object oriented Programming Using C++

Why design? · · · 2

I Can’t develop code directly from specifications of a largesystem

I System to be implemented needs a well documentedrepresentation

I The documentation has to be so generic in nature thatmany people understand it easily

I The documented representation can be verified,confirmed and enhanced as required

I Careful analysis is the first step in design

I It tries to identify “what is required in the system?”

I It doesn’t bother about “how is it achieved?”

B.W.Gore Object oriented Programming Using C++

Why design? · · · 2

I Can’t develop code directly from specifications of a largesystem

I System to be implemented needs a well documentedrepresentation

I The documentation has to be so generic in nature thatmany people understand it easily

I The documented representation can be verified,confirmed and enhanced as required

I Careful analysis is the first step in design

I It tries to identify “what is required in the system?”

I It doesn’t bother about “how is it achieved?”

B.W.Gore Object oriented Programming Using C++

Why design? · · · 2

I Can’t develop code directly from specifications of a largesystem

I System to be implemented needs a well documentedrepresentation

I The documentation has to be so generic in nature thatmany people understand it easily

I The documented representation can be verified,confirmed and enhanced as required

I Careful analysis is the first step in design

I It tries to identify “what is required in the system?”

I It doesn’t bother about “how is it achieved?”

B.W.Gore Object oriented Programming Using C++

Why design? · · · 2

I Can’t develop code directly from specifications of a largesystem

I System to be implemented needs a well documentedrepresentation

I The documentation has to be so generic in nature thatmany people understand it easily

I The documented representation can be verified,confirmed and enhanced as required

I Careful analysis is the first step in design

I It tries to identify “what is required in the system?”

I It doesn’t bother about “how is it achieved?”

B.W.Gore Object oriented Programming Using C++

Why design? · · · 2

I Can’t develop code directly from specifications of a largesystem

I System to be implemented needs a well documentedrepresentation

I The documentation has to be so generic in nature thatmany people understand it easily

I The documented representation can be verified,confirmed and enhanced as required

I Careful analysis is the first step in design

I It tries to identify “what is required in the system?”

I It doesn’t bother about “how is it achieved?”

B.W.Gore Object oriented Programming Using C++

Why design? · · · 2

I Can’t develop code directly from specifications of a largesystem

I System to be implemented needs a well documentedrepresentation

I The documentation has to be so generic in nature thatmany people understand it easily

I The documented representation can be verified,confirmed and enhanced as required

I Careful analysis is the first step in design

I It tries to identify “what is required in the system?”

I It doesn’t bother about “how is it achieved?”

B.W.Gore Object oriented Programming Using C++

Why design? · · · 2

I Can’t develop code directly from specifications of a largesystem

I System to be implemented needs a well documentedrepresentation

I The documentation has to be so generic in nature thatmany people understand it easily

I The documented representation can be verified,confirmed and enhanced as required

I Careful analysis is the first step in design

I It tries to identify “what is required in the system?”

I It doesn’t bother about “how is it achieved?”

B.W.Gore Object oriented Programming Using C++

Development steps

I Requirements specification

I Analysis

I Design

I Implementation

I Testing

I Maintenance

B.W.Gore Object oriented Programming Using C++

Development steps

I Requirements specification

I Analysis

I Design

I Implementation

I Testing

I Maintenance

B.W.Gore Object oriented Programming Using C++

Development steps

I Requirements specification

I Analysis

I Design

I Implementation

I Testing

I Maintenance

B.W.Gore Object oriented Programming Using C++

Development steps

I Requirements specification

I Analysis

I Design

I Implementation

I Testing

I Maintenance

B.W.Gore Object oriented Programming Using C++

Development steps

I Requirements specification

I Analysis

I Design

I Implementation

I Testing

I Maintenance

B.W.Gore Object oriented Programming Using C++

Development steps

I Requirements specification

I Analysis

I Design

I Implementation

I Testing

I Maintenance

B.W.Gore Object oriented Programming Using C++

Design

I step after analysis

I Identify how things are done

I Also identify who does them

I necessary step before implementation

I Focus is on objects, object functionality and objectinteractions

I system is viewed as a collection of collaborating andcooperating agents

I Aim is to build s/w that can be reused, refined, testedand extended

B.W.Gore Object oriented Programming Using C++

Design Process

I Who are they? – discover objects

I What do they do? – identify class responsibilities

I How do they interact? – collaborations

I In order to discover these aspects, walk through thespecifications and scenarios

I Every activity in the system must be identified andassigned to some component as a responsibility

B.W.Gore Object oriented Programming Using C++

Design Process

I Who are they? – discover objects

I What do they do? – identify class responsibilities

I How do they interact? – collaborations

I In order to discover these aspects, walk through thespecifications and scenarios

I Every activity in the system must be identified andassigned to some component as a responsibility

B.W.Gore Object oriented Programming Using C++

Design Process

I Who are they? – discover objects

I What do they do? – identify class responsibilities

I How do they interact? – collaborations

I In order to discover these aspects, walk through thespecifications and scenarios

I Every activity in the system must be identified andassigned to some component as a responsibility

B.W.Gore Object oriented Programming Using C++

Design Process

I Who are they? – discover objects

I What do they do? – identify class responsibilities

I How do they interact? – collaborations

I In order to discover these aspects, walk through thespecifications and scenarios

I Every activity in the system must be identified andassigned to some component as a responsibility

B.W.Gore Object oriented Programming Using C++

Design Process

I Who are they? – discover objects

I What do they do? – identify class responsibilities

I How do they interact? – collaborations

I In order to discover these aspects, walk through thespecifications and scenarios

I Every activity in the system must be identified andassigned to some component as a responsibility

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Bertrand Meyer: “Classes are there for the picking”

I Brad Cox: “An object is a software IC”

I James Rumbaugh: “An object is simply somethingthat makes sense in the application context”

I Grady Booch: “There is no such thing as a perfectclass or a perfect class structure”

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Bertrand Meyer: “Classes are there for the picking”

I Brad Cox: “An object is a software IC”

I James Rumbaugh: “An object is simply somethingthat makes sense in the application context”

I Grady Booch: “There is no such thing as a perfectclass or a perfect class structure”

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Bertrand Meyer: “Classes are there for the picking”

I Brad Cox: “An object is a software IC”

I James Rumbaugh: “An object is simply somethingthat makes sense in the application context”

I Grady Booch: “There is no such thing as a perfectclass or a perfect class structure”

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Bertrand Meyer: “Classes are there for the picking”

I Brad Cox: “An object is a software IC”

I James Rumbaugh: “An object is simply somethingthat makes sense in the application context”

I Grady Booch: “There is no such thing as a perfectclass or a perfect class structure”

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Look for nouns: omit plurals

I Model physical objects

I Also model conceptual entities that form a cohesiveabstraction

I Be careful & wary about adjectives

I Look for values of attributes

I look for hierarchies – choose commonalities that arerelevant to the system –A laser beam and a goldfish are similar –both can’t sing!

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Look for nouns: omit plurals

I Model physical objects

I Also model conceptual entities that form a cohesiveabstraction

I Be careful & wary about adjectives

I Look for values of attributes

I look for hierarchies – choose commonalities that arerelevant to the system –A laser beam and a goldfish are similar –both can’t sing!

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Look for nouns: omit plurals

I Model physical objects

I Also model conceptual entities that form a cohesiveabstraction

I Be careful & wary about adjectives

I Look for values of attributes

I look for hierarchies – choose commonalities that arerelevant to the system –A laser beam and a goldfish are similar –both can’t sing!

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Look for nouns: omit plurals

I Model physical objects

I Also model conceptual entities that form a cohesiveabstraction

I Be careful & wary about adjectives

I Look for values of attributes

I look for hierarchies – choose commonalities that arerelevant to the system –A laser beam and a goldfish are similar –both can’t sing!

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Look for nouns: omit plurals

I Model physical objects

I Also model conceptual entities that form a cohesiveabstraction

I Be careful & wary about adjectives

I Look for values of attributes

I look for hierarchies – choose commonalities that arerelevant to the system –A laser beam and a goldfish are similar –both can’t sing!

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Look for nouns: omit plurals

I Model physical objects

I Also model conceptual entities that form a cohesiveabstraction

I Be careful & wary about adjectives

I Look for values of attributes

I look for hierarchies – choose commonalities that arerelevant to the system –

A laser beam and a goldfish are similar –both can’t sing!

B.W.Gore Object oriented Programming Using C++

Choosing classes

I Look for nouns: omit plurals

I Model physical objects

I Also model conceptual entities that form a cohesiveabstraction

I Be careful & wary about adjectives

I Look for values of attributes

I look for hierarchies – choose commonalities that arerelevant to the system –A laser beam and a goldfish are similar –both can’t sing!

B.W.Gore Object oriented Programming Using C++

Class Hierarchies

I Initial design and identified classes need to be refined

I can be done by arranging classes into hierarchies

I hierarchies help identify inheritance and commonaltiesbetween classes

I hierarchies can be identified using– graphs or Venndiagrams and contracts

B.W.Gore Object oriented Programming Using C++

Class Hierarchies

I Initial design and identified classes need to be refined

I can be done by arranging classes into hierarchies

I hierarchies help identify inheritance and commonaltiesbetween classes

I hierarchies can be identified using– graphs or Venndiagrams and contracts

B.W.Gore Object oriented Programming Using C++

Class Hierarchies

I Initial design and identified classes need to be refined

I can be done by arranging classes into hierarchies

I hierarchies help identify inheritance and commonaltiesbetween classes

I hierarchies can be identified using– graphs or Venndiagrams and contracts

B.W.Gore Object oriented Programming Using C++

Class Hierarchies

I Initial design and identified classes need to be refined

I can be done by arranging classes into hierarchies

I hierarchies help identify inheritance and commonaltiesbetween classes

I hierarchies can be identified using– graphs or Venndiagrams and contracts

B.W.Gore Object oriented Programming Using C++

Class Responsibilities

I Objects are queried as to what they can do

I Each object answers in two parts–

1. what steps need to be taken by it towards accomplishingeach goal

2. what it needs to know to accomplish the given task

I Identify each action that must get accomplished

I identify the owner class for each task

B.W.Gore Object oriented Programming Using C++

Class Responsibilities

I Objects are queried as to what they can do

I Each object answers in two parts–

1. what steps need to be taken by it towards accomplishingeach goal

2. what it needs to know to accomplish the given task

I Identify each action that must get accomplished

I identify the owner class for each task

B.W.Gore Object oriented Programming Using C++

Class Responsibilities

I Objects are queried as to what they can do

I Each object answers in two parts–

1. what steps need to be taken by it towards accomplishingeach goal

2. what it needs to know to accomplish the given task

I Identify each action that must get accomplished

I identify the owner class for each task

B.W.Gore Object oriented Programming Using C++

Class Responsibilities

I Objects are queried as to what they can do

I Each object answers in two parts–

1. what steps need to be taken by it towards accomplishingeach goal

2. what it needs to know to accomplish the given task

I Identify each action that must get accomplished

I identify the owner class for each task

B.W.Gore Object oriented Programming Using C++

Class Responsibilities

I Objects are queried as to what they can do

I Each object answers in two parts–

1. what steps need to be taken by it towards accomplishingeach goal

2. what it needs to know to accomplish the given task

I Identify each action that must get accomplished

I identify the owner class for each task

B.W.Gore Object oriented Programming Using C++

Class Responsibilities

I Objects are queried as to what they can do

I Each object answers in two parts–

1. what steps need to be taken by it towards accomplishingeach goal

2. what it needs to know to accomplish the given task

I Identify each action that must get accomplished

I identify the owner class for each task

B.W.Gore Object oriented Programming Using C++

What are Class Responsibilities?

I knowledge an object maintains

I action the object can perform

I they are meant to convey a sense of “purpose of eachobject” and “its place in system”

I the services an object provides to other objects in system(for all the contracts it supports)

I some actions are internal (like mannerisms) some arepublicly available

B.W.Gore Object oriented Programming Using C++

What are Class Responsibilities?

I knowledge an object maintains

I action the object can perform

I they are meant to convey a sense of “purpose of eachobject” and “its place in system”

I the services an object provides to other objects in system(for all the contracts it supports)

I some actions are internal (like mannerisms) some arepublicly available

B.W.Gore Object oriented Programming Using C++

What are Class Responsibilities?

I knowledge an object maintains

I action the object can perform

I they are meant to convey a sense of “purpose of eachobject” and “its place in system”

I the services an object provides to other objects in system(for all the contracts it supports)

I some actions are internal (like mannerisms) some arepublicly available

B.W.Gore Object oriented Programming Using C++

What are Class Responsibilities?

I knowledge an object maintains

I action the object can perform

I they are meant to convey a sense of “purpose of eachobject” and “its place in system”

I the services an object provides to other objects in system(for all the contracts it supports)

I some actions are internal (like mannerisms) some arepublicly available

B.W.Gore Object oriented Programming Using C++

What are Class Responsibilities?

I knowledge an object maintains

I action the object can perform

I they are meant to convey a sense of “purpose of eachobject” and “its place in system”

I the services an object provides to other objects in system(for all the contracts it supports)

I some actions are internal (like mannerisms) some arepublicly available

B.W.Gore Object oriented Programming Using C++

Identifying Class Responsibilities

I Look for verbs in requirement specifications

I they give list of all probable responsibilities

I choose only appropriate verbs

I share these responsibilities among different objects, givingconsideration to the natural characteristics of the objects

I look for phrases like

1. is-kind-of2. is analogous to3. is part of

B.W.Gore Object oriented Programming Using C++

Identifying Class Responsibilities

I Look for verbs in requirement specifications

I they give list of all probable responsibilities

I choose only appropriate verbs

I share these responsibilities among different objects, givingconsideration to the natural characteristics of the objects

I look for phrases like

1. is-kind-of2. is analogous to3. is part of

B.W.Gore Object oriented Programming Using C++

Identifying Class Responsibilities

I Look for verbs in requirement specifications

I they give list of all probable responsibilities

I choose only appropriate verbs

I share these responsibilities among different objects, givingconsideration to the natural characteristics of the objects

I look for phrases like

1. is-kind-of2. is analogous to3. is part of

B.W.Gore Object oriented Programming Using C++

Identifying Class Responsibilities

I Look for verbs in requirement specifications

I they give list of all probable responsibilities

I choose only appropriate verbs

I share these responsibilities among different objects, givingconsideration to the natural characteristics of the objects

I look for phrases like

1. is-kind-of2. is analogous to3. is part of

B.W.Gore Object oriented Programming Using C++

Identifying Class Responsibilities

I Look for verbs in requirement specifications

I they give list of all probable responsibilities

I choose only appropriate verbs

I share these responsibilities among different objects, givingconsideration to the natural characteristics of the objects

I look for phrases like

1. is-kind-of

2. is analogous to3. is part of

B.W.Gore Object oriented Programming Using C++

Identifying Class Responsibilities

I Look for verbs in requirement specifications

I they give list of all probable responsibilities

I choose only appropriate verbs

I share these responsibilities among different objects, givingconsideration to the natural characteristics of the objects

I look for phrases like

1. is-kind-of2. is analogous to

3. is part of

B.W.Gore Object oriented Programming Using C++

Identifying Class Responsibilities

I Look for verbs in requirement specifications

I they give list of all probable responsibilities

I choose only appropriate verbs

I share these responsibilities among different objects, givingconsideration to the natural characteristics of the objects

I look for phrases like

1. is-kind-of2. is analogous to3. is part of

B.W.Gore Object oriented Programming Using C++

Next time · · ·

More OO concepts & example

B.W.Gore Object oriented Programming Using C++


Recommended