1 / 24

Object-Oriented Analysis

Object-Oriented Analysis. Barb Ericson ericson@cc.gatech.edu Jan 2005. 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

Download Presentation

Object-Oriented Analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object-Oriented Analysis Barb Ericson ericson@cc.gatech.edu Jan 2005 Georgia Institute of Technology

  2. 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 Georgia Institute of Technology

  3. 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 Georgia Institute of Technology

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

  5. 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 Georgia Institute of Technology

  6. 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 Customer Maid Room Georgia Institute of Technology

  7. CRC Cards Example Clerk Customer Customer Maid Stays in hotel Room Clerk Checks customer in and out Manages maids Maid Room Customer Maid Cleans room Room Clerk Place for customer to stay Georgia Institute of Technology

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

  9. 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? Georgia Institute of Technology

  10. CRC Card Practice Ideas • Do CRC cards for the movie scenario • Do CRC cards for a game of blackjack • Do CRC cards for a game of solitaire • 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 soccer game • Do CRC cards for an ATM Georgia Institute of Technology

  11. 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. Georgia Institute of Technology

  12. 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/formal/uml.htm Georgia Institute of Technology

  13. UML Tools • Popular Tools • Rational Rose – http://www.rational.com • Market leader but expensive • Visio – http://www.microsoft.com/office/visio • Poseidon - http://www.gentleware.com/ • Free community edition • ArgoUML - http://argouml.tigris.org/ • Links to sites that list UML Tools is at • http://www.omg.org/technology/uml/index.htm#Links-Methodologies Georgia Institute of Technology

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

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

  16. 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. Ocassionally protected is used which subclasses can override Georgia Institute of Technology

  17. 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 Georgia Institute of Technology

  18. 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 Georgia Institute of Technology

  19. 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 Georgia Institute of Technology

  20. 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 Georgia Institute of Technology

  21. 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 Georgia Institute of Technology

  22. UML Challenge • Draw a class diagram for Solitaire Georgia Institute of Technology

  23. Solitaire Class Diagram Georgia Institute of Technology

  24. 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) Georgia Institute of Technology

More Related