OOAD Adapted from Object Oriented Analysis and Design Methodology A Tech Talk by Ed Sullivan.

32
OOAD OOAD Adapted from Adapted from Object Oriented Analysis Object Oriented Analysis and Design Methodology and Design Methodology A Tech Talk by Ed A Tech Talk by Ed Sullivan Sullivan

Transcript of OOAD Adapted from Object Oriented Analysis and Design Methodology A Tech Talk by Ed Sullivan.

OOADOOAD

Adapted from Adapted from

Object Oriented Analysis and Object Oriented Analysis and Design MethodologyDesign Methodology

A Tech Talk by Ed SullivanA Tech Talk by Ed Sullivan

Today’s DiscussionToday’s Discussion

Background – Why OO is hotBackground – Why OO is hot OO Methodology – Java Factory OO Methodology – Java Factory

ApproachApproach Hands on application of CRC Hands on application of CRC

MethodologyMethodology

Object Oriented HeadlinesObject Oriented Headlines

“Object-Oriented Technology

Ventures Into the Real World”

“IBM unveils new object-oriented m

iddleware”“Expo to serve up object-oriented products”

“Object-Oriented is Here to Stay”

Motivation For OOADMotivation For OOADTraditional Methodologies are broken Traditional Methodologies are broken

because…because… They haven’t solved problems of quality and They haven’t solved problems of quality and

timeliness.timeliness. They separates data from procedures They separates data from procedures

making software reusability more difficult.making software reusability more difficult. They don’t work well in our non-linear world.They don’t work well in our non-linear world.

Linear vs. Non-linearLinear vs. Non-linear

LinearLinear Non-LinearNon-Linear

Step 1

Step 2

Step 3

Page 1 Page 2

Page 3 Page 4

OOAD Vs. OOAD Vs. Traditional ApproachTraditional Approach

Process is less rigorousProcess is less rigorous– Analysis ParalysisAnalysis Paralysis

Process is more fluidProcess is more fluid– Waterfall vs. OnionWaterfall vs. Onion

No definitive stopping pointNo definitive stopping point– How many iterations?How many iterations?

More Trial and Error…More Trial and Error…““I failed my way to success.”I failed my way to success.”

Thomas EdisonThomas Edison

OOAD Methodology RootsOOAD Methodology Roots

Unified Modeling Language(UML)Unified Modeling Language(UML)– Use CasesUse Cases– Class DiagramsClass Diagrams

Sun Microsystems Java factorySun Microsystems Java factory– CRC MethodologyCRC Methodology

ClassClass ResponsibilityResponsibility CollaborationCollaboration

Defining the ProcessDefining the Process Determine the RequirementsDetermine the Requirements Identify the Classes and ObjectsIdentify the Classes and Objects Describe the Object Collaborations Describe the Object Collaborations

and the classesand the classes Sketch the User InterfaceSketch the User Interface

Diagram of OOADDiagram of OOAD

Class Diagram

Determine

Requirements

Identify Classes & Objects

Describe Collaboration

Sketch Interface

Summary CRC Cards ColloborationDiagrams

Interface Sketch

Determining Determining RequirementsRequirements

Summary ParagraphSummary Paragraph– Define general approach to solving Define general approach to solving

problemproblem– Emphasize the what and not the howEmphasize the what and not the how– Describe all major Describe all major

functions(operations/methods)functions(operations/methods)– Define boundariesDefine boundaries

Sample Problem SummarySample Problem Summary

Bug Rental Application

The Renter application tracks theinventory of bugs. Initially, there are fivebugs available. The user can rent a bug,which decreases the remaininginventory. The user can return a bug,which increases inventory. Whenever abug is rented or returned, the applicationdisplays a message confirming theaction. If the user tries to rent a bugwhen none are available (inventory iszero), the application displays an errormessage.

Identifying Classes and ObjectsIdentifying Classes and Objects

CRC Card PreparationCRC Card Preparation– Class(data attributes)Class(data attributes)– Responsibility(Message response)Responsibility(Message response)– Collaboration(Class interaction)Collaboration(Class interaction)

Class DefinitionClass Definition

Classes are the templates or Classes are the templates or blueprints for objectsblueprints for objects

Classes define the attributes and Classes define the attributes and behavior(methods) for objectsbehavior(methods) for objects

Objects contain the data and the Objects contain the data and the methodsmethods

Objects are the nouns of the Object Objects are the nouns of the Object Oriented worldOriented world

So how do you define So how do you define Classes?? Classes??

1) Read Problem Summary 1) Read Problem Summary statement for nouns and noun statement for nouns and noun phrases which may be physical phrases which may be physical objects, concepts, categories objects, concepts, categories of objects or attributes of of objects or attributes of other objects. Create a list of other objects. Create a list of all of these items.all of these items.

2) Review list for Class 2) Review list for Class candidates. Transfer classes to candidates. Transfer classes to CRC card.CRC card.

Sample Problem SummarySample Problem Summary

Bug Rental Application

The Renter application tracks theinventory of bugs. Initially, there are fivebugs available. The user can rent a bug,which decreases the remaininginventory. The user can return a bug,which increases inventory. Whenever abug is rented or returned, the applicationdisplays a message confirming theaction. If the user tries to rent a bugwhen none are available (inventory iszero), the application displays an errormessage.

Noun PhrasesNoun Phrases

Renter ApplicationRenter Application BugsBugs InventoryInventory UserUser MessageMessage

Transitioning Nouns to Transitioning Nouns to ClassesClasses

Not always easyNot always easy IterativeIterative ExperienceExperience Steps…Steps…

– Logical Groupings and Logical Groupings and LevelingLeveling

– Identify Implied ClassesIdentify Implied Classes– Eliminate Eliminate

noise(primitives, noise(primitives, attributes, messages)attributes, messages)

““Design Decisions have no obvious right and wrong Design Decisions have no obvious right and wrong answers.”answers.”

Noun PhrasesNoun Phrases Class Class StepsSteps

Renter Renter ApplicationApplication

BugsBugs InventoryInventory UserUser MessageMessage

Logical Logical Groupings/LevelingGroupings/Leveling

Implied ClassesImplied Classes Noise eliminationNoise elimination

So what are the Classes of So what are the Classes of the Bug Rental the Bug Rental Application?? Application??

RenterRenter LenderLender InventoryInventory

CRC Card - FrontCRC Card - Front

Class: Renter

Responsibilities: Collaborations:

(Front of Card)

Defining ResponsibilitiesDefining Responsibilities

Use Problem Statement to identify Use Problem Statement to identify verbsverbs

Logical group and organize action Logical group and organize action itemsitems

Match Method to ClassMatch Method to Class Adjust for any omissionsAdjust for any omissions

MethodMethod VerbsVerbs

IdentificationIdentification

Track InventoryTrack Inventory Rent BugRent Bug Decrease Decrease

InventoryInventory Return BugReturn Bug Increase Increase

InventoryInventory Display MessageDisplay Message

Logical GroupingLogical Grouping LevelingLeveling Match Method to Match Method to

ClassClass

Bug Rental Bug Rental MethodsMethods

RenterRenter– Rent BugRent Bug– Return BugReturn Bug– Display MessageDisplay Message

LenderLender– Rent BugRent Bug– Return BugReturn Bug– Supply MessageSupply Message

Describing CollaborationDescribing Collaboration

Develop Use-case scenariosDevelop Use-case scenarios– Sequence of related eventsSequence of related events

Walk Through Use-casesWalk Through Use-cases– Identify message exchangesIdentify message exchanges– Identify missed ClassesIdentify missed Classes

Identify Use-Case Identify Use-Case ScenariosScenarios

Customer Rents a BugCustomer Rents a Bug1 ) Customer enters request for bug) Customer enters request for bug2 ) Lender checks inventory for bug availability) Lender checks inventory for bug availability3 ) If inventory is greater than zero) If inventory is greater than zero

• Inventory is decreased by oneInventory is decreased by one• Bug is made available to CustomerBug is made available to Customer• Message is sent to Customer from LenderMessage is sent to Customer from Lender

4 ) If inventory is zero, error message is sent to ) If inventory is zero, error message is sent to customer from Lendercustomer from Lender

Now it’s your turn…Now it’s your turn…Develop Use-Case for Bug Develop Use-Case for Bug

ReturnsReturns

Customer returns bugCustomer returns bug Lender increases inventoryLender increases inventory Lender sends message to Lender sends message to

CustomerCustomer

CRC Card - FrontCRC Card - Front

Class: Renter

Responsibilities: Collaborations:

(Front of Card)

Rent Bug

Return Bug

Display Message

Lender

Lender

N/A

Identifying AttributesIdentifying Attributes

Characteristics of ClassCharacteristics of Class Adjectives of the Object Oriented Adjectives of the Object Oriented

WorldWorld Inventory ExampleInventory Example

– Bug IDBug ID– Bug DescriptionBug Description– Bug VersionBug Version

Your turn again…Your turn again…Develop some common Develop some common attributes for the Renterattributes for the Renter

Customer NameCustomer Name Customer AddressCustomer Address Customer StatusCustomer Status Customer RentalsCustomer Rentals Customer BalanceCustomer Balance

CRC Card - BackCRC Card - Back

Attributes:

Developing a Class Developing a Class DiagramDiagram

Class Name

Attributes

Methods

CRC AdjustmentsCRC Adjustments

Create new CRC cardsCreate new CRC cards Trash invalid CRC cardsTrash invalid CRC cards Challenge yourselfChallenge yourself

– Not a cookbookNot a cookbook– Process is not magic;requires critical Process is not magic;requires critical

thinking skillsthinking skills Iterate!Iterate!