360 likes | 728 Vues
OOAD. Adapted from Object Oriented Analysis and Design Methodology A Tech Talk by Ed Sullivan. Today’s Discussion. Background – Why OO is hot OO Methodology – Java Factory Approach Hands on application of CRC Methodology. Object Oriented Headlines.
E N D
OOAD Adapted from Object Oriented Analysis and Design Methodology A Tech Talk by Ed Sullivan
Today’s Discussion • Background – Why OO is hot • OO Methodology – Java Factory Approach • Hands on application of CRC Methodology
Object Oriented Headlines “Object-Oriented Technology Ventures Into the Real World” “IBM unveils new object-oriented middleware” “Expo to serve up object-oriented products” “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 Non-Linear Page 1 Page 2 Step 1 Step 2 Page 3 Page 4 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 Identify Classes & Objects Describe Collaboration Sketch Interface ColloborationDiagrams Interface Sketch Summary CRC Cards
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
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.
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.”
Renter Application Bugs Inventory User Message Logical Groupings/Leveling Implied Classes Noise elimination Noun Phrases Class Steps
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
Track Inventory Rent Bug Decrease Inventory Return Bug Increase Inventory Display Message Logical Grouping Leveling Match Method to Class Method Verbs Identification
Renter Rent Bug Return Bug Display Message Lender Rent Bug Return Bug Supply Message Bug Rental Methods
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 • ) Customer enters request for bug • ) Lender checks inventory for bug availability • ) If inventory is greater than zero • Inventory is decreased by one • Bug is made available to Customer • Message is sent to Customer from Lender • ) 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 Collaborations: Responsibilities: Lender Lender N/A Rent Bug Return Bug Display Message (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 Name • Customer Address • Customer Status • Customer Rentals • Customer 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!