identifying classes and objects - piazza

52
Identifying Classes and Objects Object Oriented Analysis TSRK Prasad Department of CSE BITS, Pilani - KK Birla Goa Campus Object Oriented Programming

Upload: others

Post on 13-Nov-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Identifying Classes and Objects - Piazza

Identifying Classes and ObjectsObject Oriented Analysis

TSRK Prasad

Department of CSEBITS, Pilani - KK Birla Goa Campus

Object Oriented Programming

Page 2: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Lecture Outline

1 Classical Approaches

2 Structured Analysis

3 Informal English Description

4 Domain Analysis

5 Object Behavioral Analysis

6 CRC Cards

7 Use Case Analysis2 / 25

Page 3: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Lecture Outline

1 Classical Approaches

2 Structured Analysis

3 Informal English Description

4 Domain Analysis

5 Object Behavioral Analysis

6 CRC Cards

7 Use Case Analysis3 / 25

Page 4: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Classical Approaches

Derive classes based on ideas of classification.

Shaler and Mellor:Tangible things, Roles, Events, Interactions

Ross:People, Places, Things, Organizations, Concepts, Events

Coad and Yourdon:Structure, Other Systems, Devices, Events Remembered,Roles Played, Locations, Organizational Units

Classical Approaches 4 / 25

Page 5: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Classical Approaches

Derive classes based on ideas of classification.

Shaler and Mellor:Tangible things, Roles, Events, Interactions

Ross:People, Places, Things, Organizations, Concepts, Events

Coad and Yourdon:Structure, Other Systems, Devices, Events Remembered,Roles Played, Locations, Organizational Units

Classical Approaches 4 / 25

Page 6: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Classical Approaches

Derive classes based on ideas of classification.

Shaler and Mellor:Tangible things, Roles, Events, Interactions

Ross:People, Places, Things, Organizations, Concepts, Events

Coad and Yourdon:Structure, Other Systems, Devices, Events Remembered,Roles Played, Locations, Organizational Units

Classical Approaches 4 / 25

Page 7: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Classical Approaches

Derive classes based on ideas of classification.

Shaler and Mellor:Tangible things, Roles, Events, Interactions

Ross:People, Places, Things, Organizations, Concepts, Events

Coad and Yourdon:Structure, Other Systems, Devices, Events Remembered,Roles Played, Locations, Organizational Units

Classical Approaches 4 / 25

Page 8: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example

Identify classes for a tourist operator (ex: Paulo Travels) usingclassical approaches.

Tangible Things – office, bus, location, garage, seat, waitinghall, route, trip, . . .

Roles – employee, driver, passenger, agent, godown, . . .Events – repair, halt, breakdown, trip start, . . .Interactions – book ticket, drop passenger, board passenger,book luggage, . . .Organizations – operations unit, franchise, web division, garage,. . .Locations – city, town, village, bypass, . . .Other Systems – toll gates, revenue department, bus dealers,. . .

Classical Approaches 5 / 25

Page 9: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example

Identify classes for a tourist operator (ex: Paulo Travels) usingclassical approaches.

Tangible Things – office, bus, location, garage, seat, waitinghall, route, trip, . . .Roles – employee, driver, passenger, agent, godown, . . .

Events – repair, halt, breakdown, trip start, . . .Interactions – book ticket, drop passenger, board passenger,book luggage, . . .Organizations – operations unit, franchise, web division, garage,. . .Locations – city, town, village, bypass, . . .Other Systems – toll gates, revenue department, bus dealers,. . .

Classical Approaches 5 / 25

Page 10: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example

Identify classes for a tourist operator (ex: Paulo Travels) usingclassical approaches.

Tangible Things – office, bus, location, garage, seat, waitinghall, route, trip, . . .Roles – employee, driver, passenger, agent, godown, . . .Events – repair, halt, breakdown, trip start, . . .

Interactions – book ticket, drop passenger, board passenger,book luggage, . . .Organizations – operations unit, franchise, web division, garage,. . .Locations – city, town, village, bypass, . . .Other Systems – toll gates, revenue department, bus dealers,. . .

Classical Approaches 5 / 25

Page 11: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example

Identify classes for a tourist operator (ex: Paulo Travels) usingclassical approaches.

Tangible Things – office, bus, location, garage, seat, waitinghall, route, trip, . . .Roles – employee, driver, passenger, agent, godown, . . .Events – repair, halt, breakdown, trip start, . . .Interactions – book ticket, drop passenger, board passenger,book luggage, . . .

Organizations – operations unit, franchise, web division, garage,. . .Locations – city, town, village, bypass, . . .Other Systems – toll gates, revenue department, bus dealers,. . .

Classical Approaches 5 / 25

Page 12: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example

Identify classes for a tourist operator (ex: Paulo Travels) usingclassical approaches.

Tangible Things – office, bus, location, garage, seat, waitinghall, route, trip, . . .Roles – employee, driver, passenger, agent, godown, . . .Events – repair, halt, breakdown, trip start, . . .Interactions – book ticket, drop passenger, board passenger,book luggage, . . .Organizations – operations unit, franchise, web division, garage,. . .

Locations – city, town, village, bypass, . . .Other Systems – toll gates, revenue department, bus dealers,. . .

Classical Approaches 5 / 25

Page 13: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example

Identify classes for a tourist operator (ex: Paulo Travels) usingclassical approaches.

Tangible Things – office, bus, location, garage, seat, waitinghall, route, trip, . . .Roles – employee, driver, passenger, agent, godown, . . .Events – repair, halt, breakdown, trip start, . . .Interactions – book ticket, drop passenger, board passenger,book luggage, . . .Organizations – operations unit, franchise, web division, garage,. . .Locations – city, town, village, bypass, . . .

Other Systems – toll gates, revenue department, bus dealers,. . .

Classical Approaches 5 / 25

Page 14: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example

Identify classes for a tourist operator (ex: Paulo Travels) usingclassical approaches.

Tangible Things – office, bus, location, garage, seat, waitinghall, route, trip, . . .Roles – employee, driver, passenger, agent, godown, . . .Events – repair, halt, breakdown, trip start, . . .Interactions – book ticket, drop passenger, board passenger,book luggage, . . .Organizations – operations unit, franchise, web division, garage,. . .Locations – city, town, village, bypass, . . .Other Systems – toll gates, revenue department, bus dealers,. . .

Classical Approaches 5 / 25

Page 15: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Lecture Outline

1 Classical Approaches

2 Structured Analysis

3 Informal English Description

4 Domain Analysis

5 Object Behavioral Analysis

6 CRC Cards

7 Use Case AnalysisStructured Analysis 6 / 25

Page 16: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Structured Analysis

Idea: Use structural analysis as front-end to Object-orienteddesign

Obtain candidate objects from:External entities, data stores, control stores, controltransformations

Obtain candidate classes from:data flows, control flows

Not recommended approach

Structured Analysis 7 / 25

Page 17: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Structured Analysis

Idea: Use structural analysis as front-end to Object-orienteddesign

Obtain candidate objects from:External entities, data stores, control stores, controltransformations

Obtain candidate classes from:data flows, control flows

Not recommended approach

Structured Analysis 7 / 25

Page 18: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Structured Analysis

Idea: Use structural analysis as front-end to Object-orienteddesign

Obtain candidate objects from:External entities, data stores, control stores, controltransformations

Obtain candidate classes from:data flows, control flows

Not recommended approach

Structured Analysis 7 / 25

Page 19: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Structured Analysis

Idea: Use structural analysis as front-end to Object-orienteddesign

Obtain candidate objects from:External entities, data stores, control stores, controltransformations

Obtain candidate classes from:data flows, control flows

Not recommended approach

Structured Analysis 7 / 25

Page 20: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Data Flow and Control Flow Diagrams

Data Flow Diagram:

Control Flow Diagram:

Structured Analysis 8 / 25

Page 21: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Data Flow and Control Flow Diagrams

Data Flow Diagram:

Control Flow Diagram:

Structured Analysis 8 / 25

Page 22: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Lecture Outline

1 Classical Approaches

2 Structured Analysis

3 Informal English Description

4 Domain Analysis

5 Object Behavioral Analysis

6 CRC Cards

7 Use Case AnalysisInformal English Description 9 / 25

Page 23: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Informal English Description

nouns ÝÑ objects

verbs ÝÑ operations

Problem? Nouns can be verbed, verbs can be nouned.

Informal English Description 10 / 25

Page 24: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Informal English Description

nouns ÝÑ objectsverbs ÝÑ operations

Problem? Nouns can be verbed, verbs can be nouned.

Informal English Description 10 / 25

Page 25: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Informal English Description

nouns ÝÑ objectsverbs ÝÑ operations

Problem? Nouns can be verbed, verbs can be nouned.

Informal English Description 10 / 25

Page 26: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example on Informal English Description

... If a customer enters a store with the intention of buying a toyfor a child, then advice must be available within a reasonabletime concerning the suitability of the toy for the child. This willdepend on the age range of the child and the attributes of thetoy. If the toy is a dangerous item, then it is unsuitable. ...

Ans:... If a customer enters a store with the intention of buying a toyfor a child, then advice must be available within a reasonabletime concerning the suitability of the toy for the child. This willdepend on the age range of the child and the attributes of thetoy. If the toy is a dangerous item, then it is unsuitable. ...

Notation: class operation attributes/associations

Informal English Description 11 / 25

Page 27: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example on Informal English Description

... If a customer enters a store with the intention of buying a toyfor a child, then advice must be available within a reasonabletime concerning the suitability of the toy for the child. This willdepend on the age range of the child and the attributes of thetoy. If the toy is a dangerous item, then it is unsuitable. ...

Ans:... If a customer enters a store with the intention of buying a toyfor a child, then advice must be available within a reasonabletime concerning the suitability of the toy for the child. This willdepend on the age range of the child and the attributes of thetoy. If the toy is a dangerous item, then it is unsuitable. ...

Notation: class operation attributes/associationsInformal English Description 11 / 25

Page 28: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

On Thinking/Communication

12 / 25

Page 29: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Lecture Outline

1 Classical Approaches

2 Structured Analysis

3 Informal English Description

4 Domain Analysis

5 Object Behavioral Analysis

6 CRC Cards

7 Use Case AnalysisDomain Analysis 13 / 25

Page 30: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Domain Analysis

Idea: Identify classes and objects that are common to allapplications with in a given domain.

Moore and Bailin Approach:1 Construct strawman model of domain2 Construct/collect models of existing softwares serving the

domain3 Reconcile the differences4 Refine strawman model to accommodate existing models

Domain Analysis 14 / 25

Page 31: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Domain Analysis

Idea: Identify classes and objects that are common to allapplications with in a given domain.

Moore and Bailin Approach:1 Construct strawman model of domain

2 Construct/collect models of existing softwares serving thedomain

3 Reconcile the differences4 Refine strawman model to accommodate existing models

Domain Analysis 14 / 25

Page 32: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Domain Analysis

Idea: Identify classes and objects that are common to allapplications with in a given domain.

Moore and Bailin Approach:1 Construct strawman model of domain2 Construct/collect models of existing softwares serving the

domain

3 Reconcile the differences4 Refine strawman model to accommodate existing models

Domain Analysis 14 / 25

Page 33: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Domain Analysis

Idea: Identify classes and objects that are common to allapplications with in a given domain.

Moore and Bailin Approach:1 Construct strawman model of domain2 Construct/collect models of existing softwares serving the

domain3 Reconcile the differences

4 Refine strawman model to accommodate existing models

Domain Analysis 14 / 25

Page 34: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Domain Analysis

Idea: Identify classes and objects that are common to allapplications with in a given domain.

Moore and Bailin Approach:1 Construct strawman model of domain2 Construct/collect models of existing softwares serving the

domain3 Reconcile the differences4 Refine strawman model to accommodate existing models

Domain Analysis 14 / 25

Page 35: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Example on Domain Analysis

Hospital Domain

Domain Analysis 15 / 25

Page 36: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Lecture Outline

1 Classical Approaches

2 Structured Analysis

3 Informal English Description

4 Domain Analysis

5 Object Behavioral Analysis

6 CRC Cards

7 Use Case AnalysisObject Behavioral Analysis 16 / 25

Page 37: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Object Behavioral Analysis (OBA)

Idea: Form classes based on groups of objects that exhibitsimilar behavior.

Two suggestions:1 Responsibility identification

Responsibility - service provided by object(s) for allcontracts it supports.

2 Behavior allocation1 Assign system behavior to parts of the system.2 Initiators of / participants in behaviors are objects

Object Behavioral Analysis 17 / 25

Page 38: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Object Behavioral Analysis (OBA)

Idea: Form classes based on groups of objects that exhibitsimilar behavior.

Two suggestions:1 Responsibility identification

Responsibility - service provided by object(s) for allcontracts it supports.

2 Behavior allocation1 Assign system behavior to parts of the system.2 Initiators of / participants in behaviors are objects

Object Behavioral Analysis 17 / 25

Page 39: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Object Behavioral Analysis (OBA)

Idea: Form classes based on groups of objects that exhibitsimilar behavior.

Two suggestions:1 Responsibility identification

Responsibility - service provided by object(s) for allcontracts it supports.

2 Behavior allocation1 Assign system behavior to parts of the system.2 Initiators of / participants in behaviors are objects

Object Behavioral Analysis 17 / 25

Page 40: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Object Behavior Analysis (OBA) Exercise

Identify objects and behaviors in a regular OOP lab of thiscourse.

Object Behavioral Analysis 18 / 25

Page 41: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Lecture Outline

1 Classical Approaches

2 Structured Analysis

3 Informal English Description

4 Domain Analysis

5 Object Behavioral Analysis

6 CRC Cards

7 Use Case AnalysisCRC Cards 19 / 25

Page 42: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

CRC Cards

CRC stands for Class/Responsibilities/Collaborators

CRC Card Format

CRC Card for Student Class

CRC Cards 20 / 25

Page 43: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

CRC Cards

CRC stands for Class/Responsibilities/Collaborators

CRC Card Format CRC Card for Student Class

CRC Cards 20 / 25

Page 44: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

CRC Card Layout

cards can be arranged as class/object hierarchyCRC Cards 21 / 25

Page 45: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Lecture Outline

1 Classical Approaches

2 Structured Analysis

3 Informal English Description

4 Domain Analysis

5 Object Behavioral Analysis

6 CRC Cards

7 Use Case AnalysisUse Case Analysis 22 / 25

Page 46: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Use Case Analysis

A behaviourally related sequence of transactionsperformed by an actor in a dialogue with the system toprovide some measurable value to the actor.

–Jacobson et. al.

Approach: In each use case,1 Identify the participating objects (Classes)2 Identify the responsibilities of each object (Responsibilities)3 Identify the collaborations / relations between objects

(Collaborators)

Use case analysis serves as basis of system tests.

Use Case Analysis 23 / 25

Page 47: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Use Case Analysis

A behaviourally related sequence of transactionsperformed by an actor in a dialogue with the system toprovide some measurable value to the actor.

–Jacobson et. al.

Approach: In each use case,1 Identify the participating objects (Classes)

2 Identify the responsibilities of each object (Responsibilities)3 Identify the collaborations / relations between objects

(Collaborators)

Use case analysis serves as basis of system tests.

Use Case Analysis 23 / 25

Page 48: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Use Case Analysis

A behaviourally related sequence of transactionsperformed by an actor in a dialogue with the system toprovide some measurable value to the actor.

–Jacobson et. al.

Approach: In each use case,1 Identify the participating objects (Classes)2 Identify the responsibilities of each object (Responsibilities)

3 Identify the collaborations / relations between objects(Collaborators)

Use case analysis serves as basis of system tests.

Use Case Analysis 23 / 25

Page 49: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Use Case Analysis

A behaviourally related sequence of transactionsperformed by an actor in a dialogue with the system toprovide some measurable value to the actor.

–Jacobson et. al.

Approach: In each use case,1 Identify the participating objects (Classes)2 Identify the responsibilities of each object (Responsibilities)3 Identify the collaborations / relations between objects

(Collaborators)

Use case analysis serves as basis of system tests.

Use Case Analysis 23 / 25

Page 50: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Use Case Analysis

A behaviourally related sequence of transactionsperformed by an actor in a dialogue with the system toprovide some measurable value to the actor.

–Jacobson et. al.

Approach: In each use case,1 Identify the participating objects (Classes)2 Identify the responsibilities of each object (Responsibilities)3 Identify the collaborations / relations between objects

(Collaborators)

Use case analysis serves as basis of system tests.

Use Case Analysis 23 / 25

Page 51: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Fair Comparison

24 / 25

Page 52: Identifying Classes and Objects - Piazza

Identifying Classes and Objects

Acknowledgements

CRC diagrams http://agilemodeling.com/artifacts/crcModel.htmdomain-analysis.jpg http://www.cs.sjsu.edu/faculty/pearce/pop/chp1/chapter1_files/image008.gifassessment.png http://www.behaviorbabe.com/assessments.htmDFDExample.png http://upload.wikimedia.org/wikipedia/commons/c/c8/DataFlowDiagram_Example.pngCFDExample.png http://upload.wikimedia.org/wikipedia/commons/e/e3/Performance_seeking_control_flow_diagram.jpgcontrolFlow.png http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc00120.1653/

doc/html/rad1232636366142.html

25 / 25