object oriented design
play

Object-Oriented Design Lecture 6: Finding Analysis Classes Sharif - PowerPoint PPT Presentation

Object-Oriented Design Lecture 6: Finding Analysis Classes Sharif University of Technology 1 Department of Computer Engineering Analysis Workflow: Analyze a Use Case The analysis workflow consists of the following activities:


  1. Object-Oriented Design Lecture 6: Finding Analysis Classes Sharif University of Technology 1 Department of Computer Engineering

  2. Analysis Workflow: Analyze a Use Case • The analysis workflow consists of the following activities: • Architectural analysis • Analyze a use case • Outputs: • analysis classes • use case realizations • Analyze a class • Analyze a package 2 Sharif University of Technology

  3. Analysis Classes: Typical Structure • Analysis classes represent a crisp, well-defined abstraction in the problem domain. • Analysis classes include: • a set of high-level candidate attributes • a set of high-level operations 3 Sharif University of Technology

  4. Good Analysis Classes • What makes a good analysis class? • Its name reflects its intent. • It is a crisp abstraction that models one specific element of the problem domain. • It maps to a clearly identifiable feature of the problem domain. • It has a small, well-defined set of responsibilities: • a responsibility is a contract or obligation that a class has to its clients; • a responsibility is a semantically cohesive set of operations; • there should only be about three to five responsibilities per class. • It has high cohesion - all features of the class should help to realize its intent. • It has low coupling - a class should only collaborate with a small number of other classes to realize its intent. 4 Sharif University of Technology

  5. Bad Analysis Classes • What makes a bad analysis class? • A functoid - a class with only one operation. • A stand-alone class - each class should be associated with a small number of other classes with which it collaborates to deliver the desired benefit. • An omnipotent class - a class that does everything (classes with "system" or "controller" in their name may need closer scrutiny). • A class with a deep inheritance tree - in the real world inheritance trees tend to be shallow. • A class with low cohesion. • A class with high coupling. • Many very small classes in a model – merging should be considered. • Few but large classes in a model – decomposition should be considered. 5 Sharif University of Technology

  6. Class Identification Techniques • Noun/Verb Analysis ( Grammatical Parsing ) • CRC Analysis • Use-Case-Based Analysis • Real-World Analysis 6 Sharif University of Technology

  7. Order of activities in modeling Formulate a few scenarios with help from the end user and/or application 1. domain expert. Extract the use cases from the scenarios, with the help of application 2. domain expert. Analyse the flow of events , for example with Abbot's textual 3. analysis . Generate the class diagrams , which includes the following steps, as 4. before: 1. Class identification (textual analysis, domain experts). 2. Identification of attributes and operations (sometimes before the classes are found!) 3. Identification of associations between classes 4. Identification of multiplicities 5. Identification of roles 6. Identification of constraints 7

  8. Noun/verb analysis ( Grammatical Parsing ) 1. Collect as much relevant information about the problem domain as possible; suitable sources of information are: • The requirements model • The use case model • The project glossary • Any other document (architecture, vision documents, etc.) 2. Analyze the documentation: • Look for nouns or noun phrases - these are candidate classes or attributes. • Look for verbs or verb phrases - these are candidate responsibilities or operations. 3. Make a tentative allocation of the attributes and responsibilities to the classes. Sharif University of Technology 8

  9. Example: Flow of events  The customer enters a store with the intention of buying a toy for his child with the age of n.  Help must be available within less than one minute.  The store owner gives advice to the customer. The advice depends on the age range of the child and the attributes of the toy.  The customer selects a dangerous toy which is kind of unsuitable for the child.  The store owner recommends a more yellow doll. 9 Sharif University of Technology

  10. Mapping parts of speech to object model components [Abbott, 1983] Part of speech Model component Example Proper noun object Jim Smith Improper noun class Toy, doll Doing verb method Buy, recommend being verb inheritance is-a (kind-of) having verb aggregation has an modal verb constraint must be adjective attribute 3 years old transitive verb method enter intransitive verb method (event) depends on 10

  11. Generation of a class diagram from flow of events Flow of events: Customer customer enters store  The customer enters the store buy to buy a toy. It has to be a toy that his daughter likes and toy daughter store ? less than 50 Euro it must cost less than 50 Euro. videogame He tries a videogame, which enter() enter() uses a data glove and a head- mounted display. He likes it. daughter daughter age An assistant helps him. The suitability of the game depends depends suitable on the age of the child. His age * toy toy toy daughter is only 3 years old. price The assistant recommends another buy() buy() like() boardgame type of toy type of toy, namely a boardgame. The customer buy the game and boardgame videogame leaves the store Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11

  12. Another Example • The customer enters the store to buy a Flow of events: toy. • It has to be a toy that his daughter likes and it must cost less than 50 Euro. • He tries a videogame, which uses a data glove and a head-mounted display. He likes it. Is this a good use Case? An assistant helps him. The suitability of the game depends on the age of the child. His daughter is only 3 years old. Not quite! The assistant recommends another type of toy, namely the boardgame “Monopoly". The use case should terminate with the customer leaving the store

  13. Textual Analysis using Abbot‘s technique Example Grammatical construct UML Component “Monopoly" Concrete Person, Thing Object “toy" noun class "3 years old" Adjective Attribute “enters" verb Operation “depends on…." Intransitive verb Operation (Event) “is a" ,“either..or", Classifying verb Inheritance “kind of…" "Has a ", “consists of" Possessive Verb Aggregation “must be", “less than…" modal Verb Constraint

  14. CRC Analysis – CRC Cards • CRC – Class, Responsibilities, and Collaborators • Important things in the problem domain are written on CRC Cards. Each Card has three compartments: • class - contains the name of the class • responsibilities - contains a list of the responsibilities of that class (the functions it performs and even the information it is responsible to keep and provide) • collaborators - contains a list of other classes with which this class collaborates in order to fulfill the responsibilities 14 Sharif University of Technology

  15. CRC Analysis Procedure – Phase 1 • The participants are analysts, stakeholders, and domain experts. • Phase 1: Brainstorm - gather the information: 1. Explain that this is a true brainstorm. 1. All ideas are accepted as good ideas. 2. Ideas are recorded but not debated. 2. Ask the team members to name the "things" that operate in their business domain - for example, customer, product. 1. Write each thing on a sticky note; it is a candidate class, or attribute of a class. 2. Stick the note on a wall or whiteboard. 3. Ask the team to state responsibilities that those things might have; record these in the responsibilities compartment of the note. 4. Working with the team, identify classes that might work together; record 15 collaborators in the collaborators compartment of the note.

  16. CRC Analysis Procedure – Phase 2 • The participants are analysts and domain experts. • Phase 2: Decide which sticky notes should become classes and which should become attributes: • Analysis classes must represent a crisp abstraction in the problem domain. Certain sticky notes will represent key business concepts and clearly need to become classes. • If a note logically seems to be a part of another note, this is a good indication that it represents an attribute. • If a note doesn't seem to be particularly important or has very little interesting behavior, see if it can be made an attribute of another class. • If in doubt about a note, just make it a class. 16 Sharif University of Technology

  17. Use-Case-Based Analysis • Complements other techniques • Starts from an initial list of classes • List of classes is perfected and refined based on use cases: • Behavioral models are built showing use case realizations • Classes are identified based on the objects needed for use case realizations: the list of classes should provide instances which implement the behavior needed for the use cases; • New classes will be added if needed • Changes will be made to existing classes if required for use case realization 17 Sharif University of Technology

  18. Use-Case-Based Analysis – Using RUP stereotypes • RUP stereotypes can be used to focus analysis activity on three types of class 18 Sharif University of Technology

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend