OBJECT ORIENTED TECHNOLOGY
Download
Report
Transcript OBJECT ORIENTED TECHNOLOGY
OOAD
Object Oriented Analysis and
Design Methodology
Today’s Discussion
Background – Why OO is hot
OO Methodology – Java Factory Approach
Hands on application of CRC Methodology
Informal
– Questions anytime
– Food and Drink anytime
Object Oriented Headlines
“Object-Oriented is Here to Stay”
Motivation For OOAD
Traditional Methodologies are broken because…
They haven’t solved problems of quality and
timeliness.
They separates data from procedures making
software reusability more difficult.
They don’t work well in our non-linear world.
Linear vs. Non-linear
Linear
Step 1
Non-Linear
Page 1
Page 2
Page 3
Page 4
Step 2
Step 3
OOAD Vs.
Traditional Approach
Process is less rigorous
– Analysis Paralysis
Process is more fluid
– Waterfall vs. Onion
No definitive stopping point
– How many iterations?
More Trial and Error…
“I failed my way to success.”
Thomas Edison
OOAD Methodology Roots
Unified Modeling Language(UML)
– Use Cases
– Class Diagrams
Sun Microsystems Java factory
– CRC Methodology
Class
Responsibility
Collaboration
Defining the Process
Determine the Requirements
Identify the Classes and Objects
Describe the Object Collaborations and
the classes
Sketch the User Interface
Diagram of OOAD
Class
Diagram
Determine
Requirements
Summary
Identify
Classes &
Objects
Describe
Collaboration
Sketch
Interface
CRC Cards
Colloboration
Diagrams
Interface
Sketch
Determining Requirements
Summary Paragraph
– Define general approach to solving problem
– Emphasize the what and not the how
– Describe all major
functions(operations/methods)
– Define boundaries
Sample Problem Summary
Bug Rental Application
The Renter application tracks the
inventory of bugs. Initially, there are five
bugs available. The user can rent a bug,
which decreases the remaining
inventory. The user can return a bug,
which increases inventory. Whenever a
bug is rented or returned, the application
displays a message confirming the
action. If the user tries to rent a bug
when none are available (inventory is
zero), the application displays an error
message.
Identifying Classes and Objects
CRC Card Preparation
– Class(data attributes)
– Responsibility(Message response)
– Collaboration(Class interaction)
Class Definition
Classes are the templates or blueprints
for objects
Classes define the attributes and
behavior(methods) for objects
Objects contain the data and the
methods
Objects are the nouns of the Object
Oriented world
So how do you define Classes??
1) Read Problem Summary
statement for nouns and noun
phrases which may be physical
objects, concepts, categories of
objects or attributes of other
objects. Create a list of all of
these items.
2) Review list for Class
candidates. Transfer classes to
CRC card.
Sample Problem Summary
Bug Rental Application
The Renter application tracks the
inventory of bugs. Initially, there are five
bugs available. The user can rent a bug,
which decreases the remaining
inventory. The user can return a bug,
which increases inventory. Whenever a
bug is rented or returned, the application
displays a message confirming the
action. If the user tries to rent a bug
when none are available (inventory is
zero), the application displays an error
message.
Noun Phrases
Renter Application
Bugs
Inventory
User
Message
Transitioning Nouns to Classes
Not always easy
Iterative
Experience
Steps…
– Logical Groupings and
Leveling
– Identify Implied Classes
– Eliminate noise(primitives,
attributes, messages)
“Design Decisions have no obvious right and wrong answers.”
Noun Phrases
Renter Application
Bugs
Inventory
User
Message
Class Steps
Logical Groupings/Leveling
Implied Classes
Noise elimination
So what are the Classes of the
Bug Rental Application??
Renter
Lender
Inventory
CRC Card - Front
Class: Renter
Responsibilities:
Collaborations:
(Front of Card)
Defining Responsibilities
Use Problem Statement to identify verbs
Logical group and organize action items
Match Method to Class
Adjust for any omissions
Verbs
Track Inventory
Rent Bug
Decrease Inventory
Return Bug
Increase Inventory
Display Message
Method
Identification
Logical Grouping
Leveling
Match Method to Class
Bug Rental
Methods
Renter
– Rent Bug
– Return Bug
– Display Message
Lender
– Rent Bug
– Return Bug
– Supply Message
Describing Collaboration
Develop Use-case scenarios
– Sequence of related events
Walk Through Use-cases
– Identify message exchanges
– Identify missed Classes
Identify Use-Case Scenarios
Customer Rents a Bug
1 ) Customer enters request for bug
2 ) Lender checks inventory for bug availability
3 ) If inventory is greater than zero
•
•
•
Inventory is decreased by one
Bug is made available to Customer
Message is sent to Customer from Lender
4 ) If inventory is zero, error message is sent to
customer from Lender
Now it’s your turn…
Develop Use-Case for Bug Returns
Customer
returns bug
Lender increases inventory
Lender sends message to Customer
CRC Card - Front
Class: Renter
Responsibilities:
Collaborations:
Rent Bug
Lender
Return Bug
Lender
Display Message
N/A
(Front of Card)
Identifying Attributes
Characteristics of Class
Adjectives of the Object Oriented World
Inventory Example
– Bug ID
– Bug Description
– Bug Version
Your turn again…
Develop some common
attributes for the Renter
Customer
Customer
Customer
Customer
Customer
Name
Address
Status
Rentals
Balance
CRC Card - Back
Attributes:
Developing a Class Diagram
Class Name
Attributes
Methods
CRC Adjustments
Create new CRC cards
Trash invalid CRC cards
Challenge yourself
– Not a cookbook
– Process is not magic;requires critical
thinking skills
Iterate!
Next Step...
Onion Peeling(aka Iterate)
Evolve From What to How
– From abstract to detailed functionality
– Define Data Access
– Define Physical environment