Presentation is loading. Please wait.

Presentation is loading. Please wait.

Georgia Institute of Technology Object-Oriented Analysis Barb Ericson June 2006.

Similar presentations


Presentation on theme: "Georgia Institute of Technology Object-Oriented Analysis Barb Ericson June 2006."— Presentation transcript:

1 Georgia Institute of Technology Object-Oriented Analysis Barb Ericson June 2006

2 Georgia Institute of Technology Learning Goals Understand at a practical level –How to identify objects and classes –How to record potential classes –How to record responsibilities –How to record fields and methods –How to record the relationships between classes

3 Georgia Institute of Technology Objects and Classes To write an object-oriented program we need to identify the objects that we need to create –And determine how to classify them What data does an object need to keep about itself? These are the fields. What things should an object be able to do? These are the methods. Next we write a class for each classification of the needed objects

4 Georgia Institute of Technology Identifying Classes As you go through a scenario –Write down each noun you hear (or underline each noun if the scenario is written) –Put each one at the top of an index card –Write down what objects of this class are responsible for –Write down what other classes this object has to work with to accomplish it’s responsibilities

5 Georgia Institute of Technology CRC Cards Class Responsibility Collaborators Developed by Ward Cunningham and Kent Beck at Tektronix in the late 1980’s Analysis technique Classname ResponsibilitiesCollaborators

6 Georgia Institute of Technology Use and Advantages Used to –Record classes as they are identified –Record the purpose (responsibility) of each class –Record and experiment with relationships (collaborators) between classes Advantages –cheap, portable, readily available, and familiar –focus on analysis, not on a diagram –good in a group discussion

7 Georgia Institute of Technology CRC Cards Example Do an analysis of a hotel room reservation system. –The system must allow clerks to assign rooms to customers. It must also allow clerks to assign maids to clean the rooms. Clerk Maid Customer Room

8 Georgia Institute of Technology CRC Cards Example Clerk Checks customer in and out Manages maids Customer Maid Cleans roomRoom Clerk Customer Stays in hotelRoom Clerk Room Place for customer to stay Customer Maid

9 Georgia Institute of Technology CRC Card Example Clerk Checks customer in and out Assigns room Handles payment Manages maids Assigns room Customer Maid Cleans room Assigned room Cleans room Room Clerk Customer Stays in hotel Check in Check out Pay for room Use phone Room Clerk Room Place for customer to stay Customer Maid

10 Georgia Institute of Technology Abstraction Pull out only the important details about the thing we are simulating –Maids have hobbies but we don’t need to know about them What is important in the context of the problem? –What data will objects of the class need –What things will they need to be able to do?

11 Georgia Institute of Technology Analysis of Selling Items on a Web Site We want to sell items on a web site and we need to keep track of our customers and their orders –Create CRC cards for this Do a walk through of placing an order –Did you find any new objects, data, or methods that you might need? It can help to look at some sample web sites like amazon.com

12 Georgia Institute of Technology CRC Card Practice Ideas Do CRC cards for a game of battleship Do CRC cards for a game of blackjack Do CRC cards for a game of war Do CRC cards for a drawing program Do CRC cards for airplane flights Do CRC cards for a bookstore website Do CRC cards for an ATM

13 Georgia Institute of Technology Drawing Editor Exercise Identify the classes for a simple drawing editor. Also show the data and operations for the classes. –The editor can draw rectangles, circles, and triangles. It can show connections between shapes with a a line. The shapes can be erased, moved, and rotated.

14 Georgia Institute of Technology Record Class Information Can use a UML Class Diagram –Unified Modeling Language Standard way to documents OO analysis, design, and implementations UML Specification –http://www.omg.org/technology/documents/for mal/uml.htm

15 Georgia Institute of Technology UML Tools Popular Tools –Rational Rose – Market leader but expensive –Visio – –Poseidon - Free community edition –ArgoUML - –Links to sites that list UML Tools is at –http://www.omg.org/technology/uml/index.htm #Links-Methodologieshttp://www.omg.org/technology/uml/index.htm #Links-Methodologies

16 Georgia Institute of Technology Class Diagram Shows classes and the relationships between them –Static structure Not time dependent Most important and commonly used diagram in UML

17 Georgia Institute of Technology Class Representation Rectangles are used to represent classes There are different sections for the class name, attributes and operations Class Name Attribute1 Attribute2 Operation1() Operation2() Dog size shape wagTail() bark()

18 Georgia Institute of Technology Visibility Who can access the item Types of Visibility –Public (+) All can use –Private (-) Only objects of the class Attributes should be private –So the object has control of its’ data Methods are public or private –Public if intended as a service. Private if for internal use. Occasionally protected is used which subclasses can override

19 Georgia Institute of Technology Static Class Relationships Association –has-a –A connector has shapes Generalization –is-a-kind-of –A circle is a kind of shape Aggregation –is-a-part-of –A display list is an aggregation (collection) of shapes

20 Georgia Institute of Technology Dynamic Class Relationship Dependency –Uses –A car uses a parking space –It doesn’t have a have- a relationship with it Dynamic relationships are relationships that change over time

21 Georgia Institute of Technology Association Multiplicities Associations have multiplicities (one for each end) –X can have how many objects of y associated with it? –Y can have how many objects of x associated with it? Kinds of Multiplicities –m..n Inclusive range from m to n –n There must be exactly n –* or 0..* 0 to many

22 Georgia Institute of Technology Roles Each association end is a role –role A –role B Roles can be explicitly named –Especially useful when there is more than one association between the classes –Or for use in generated code

23 Georgia Institute of Technology Class Diagram Perspectives There are three perspectives that a class diagram can represent –Conceptual - Analysis Stage Language independent, represents the domain –Specification - Design Stage Represents a high level design of the solution –Implementation – Programming Stage Represents the actual solution Shows attributes, operations, types (if needed), and parameters to operations

24 Georgia Institute of Technology Bingo Exercise What objects are there in Bingo? –What data do these objects have? –What things can they do? –How do you classify them? For each class in Bingo –What is the relationship with the other classes? Draw a UML diagram for a Bingo Game

25 Georgia Institute of Technology UML Challenge Draw a class diagram for Solitaire

26 Georgia Institute of Technology Solitaire Class Diagram

27 Georgia Institute of Technology Summary In Analysis you need to understand the objects in the domain (“real world”) Figure out what the objects are responsible for –What data do they need to have? –What things can they do? UML class diagrams show lots of information in a picture –Can be helpful on exam questions About inheritance and polymorphism Determine the relationships between the classes –Has a (association) –Is a type of (inheritance)


Download ppt "Georgia Institute of Technology Object-Oriented Analysis Barb Ericson June 2006."

Similar presentations


Ads by Google