1 / 95

Chapter 9 Finding Objects and Classes in the Real World

Chapter 9 Finding Objects and Classes in the Real World. Chapter 9: Finding Objects and Classes in the Real World Outline:. 9.1. The Importance of This Step 9.2. The KRB ( K apur, R avindra & B rown) Seven-Step Method 9.3. Is It A Class or Is It An Attribute? 9.4. Finding Structures

violet-ward
Télécharger la présentation

Chapter 9 Finding Objects and Classes in the Real World

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. Chapter 9Finding Objects and Classes in the Real World

  2. Chapter 9: Finding Objects and Classes in the Real WorldOutline: 9.1. The Importance of This Step 9.2. The KRB (Kapur, Ravindra & Brown) Seven-Step Method 9.3. Is It A Class or Is It An Attribute? 9.4. Finding Structures 9.5. Adapting the Method Let’s check these 5 in detail. . .

  3. Chapter 9: Finding Objects and Classes in the Real World 9.1. The Importance of This Step. 9.2. The KRB Seven-Step Method. 9.3. Is It A Class or Is It An Attribute? 9.4. Finding Structures. 9.5. Adapting the Method.

  4. 9.1. The Importance of This Step. • The concept of classis one of the key things in the Object-Oriented world, • So one of the first steps is to find all the classes, • Allthe classes, • That matter for this project. • How do we know when we have them all (or at least close enough)? Read on. . .

  5. 9.1. The Importance of This Step. • First we must be user-driven, • That is, we must take the attitude that the users know what we need to know • To get our job done properly. • What follows is a reliable set of techniques for working with the users • To get from them what we need, • Documented the way we need it, • To build for them the right software, That they truly need.

  6. 9.1. The Importance of This Step. Jacobson’s Three Types • Entity Objects - things in the users’ real world • Concreteobjects - Employee, Product, Tool, etc. • Conceptualobjects - Corporation, strategy, membership, approval, etc. • Event and State objects - Purchase, delivery, arrival, ownership, status, etc. • Interface Objects - To encapsulate the details of GUIs, communication protocols, and the like. • Control Objects - To carry complex methods that don’t have a class they obviously belong in.

  7. 9.1. The Importance of This Step. The Class Diagram is the foundation for your entire software project!! If this is done well, You have an excellent chance of a successful project. If not, you don’t

  8. Chapter 9: Finding Objects and Classes in the Real World 9.1. The Importance of This Step. 9.2. The KRB Seven-Step Method. 9.3. Is It A Class or Is It An Attribute? 9.4. Finding Structures. 9.5. Adapting the Method.

  9. 9.2. The KRB Seven-Step Method. Step  Candidate Classes Step  Define Classes Step  Establish Relationships Step  Expand Many-to-Many Relationships Step  Attributes Step  Normalization Step  Operations (i.e., Behavior)

  10. 9.2. The KRB Seven-Step Method. Step Candidate Classes Definition: Candidate Classes: Nouns that are possible class names, being considered for inclusion in the project.

  11. 9.2. The KRB Seven-Step Method. Step Candidate ClassesEntity Classes • Things in the world of the users. • These are the four most popular methods for this step: • Client Interviews • Nouns from the Documentation • Brainstorming Now these four methods in detail . . .

  12. 9.2. The KRB Seven-Step Method. Step  Candidate Classes1. Client Interviews • Good for busy senior executives. • Adapt the group methods (Brainstorming, etc.) to individual or small-group setting. • Possibly interview them first, then build the model away from the users. • Bring the model back to the users regularly for feedback and input.

  13. 9.2. The KRB Seven-Step Method. StepCandidate Classes2. Nouns from the Documentation • Use this idea by itself, or with the others. • You need nouns. • Start with any or all of these documents: • Systems Request Document • Change Request Document • The mandate, mission, strategic plan, etc., etc. for the users’ business. • Any document that describes that portion of the users’ business which you are about to model.

  14. 9.2. The KRB Seven-Step Method. StepCandidate Classes2. Nouns from the DocumentationAlso go through your own documents: • Your Requirements Models • Project Scope • Context Diagram • Use Cases • Interface descriptions • And any other document that you think might be a fruitful source of nounsconcerned in your users’ business.

  15. 9.2. The KRB Seven-Step Method. StepCandidate Classes3. Brainstorming Our Class Diagram must be based • Not on the needs of the current project, • But on the total data requirements of the users’ business area. The brainstorming method does just that . . .

  16. 9.2. The KRB Seven-Step Method. StepCandidate Classes3. Brainstorming Definition: • Formal Brainstormingtakes place in two distinct phases. • The first phase is for generatingideas, • and the secondphase is for evaluatingthose ideas.

  17. 9.2. The KRB Seven-Step Method. Step Candidate Classes Interface Classes • User Interfaces: • Your classes will be defined by your GUI tool. • Data Communications Interfaces: • If you buy a communications class library, your classes are already defined for you. • The published comm protocol should be filed with or referred from your project documentation. • Real-world systems to control or monitor: • Industrial Processes, etc. • Define a single-instance class to represent the external system.

  18. 9.2. The KRB Seven-Step Method. Step Candidate Classes Control Classes • Will mostly be discovered in the Design Phase of the OODLC. • As with anything else, if the topic arises earlier during the Analysis Phase, • Use you judgement; • Either do it now, or • Make serious notes to ensureit gets done later. (Don’t ever miss it!)

  19. 9.2. The KRB Seven-Step Method. Step  Candidate Classes Step Define Classes Step  Establish Associations Step  Expand Many-to-Many Associations Step  Attributes Step  Normalization Step  Operations (i.e., Behavior)

  20. 9.2. The KRB Seven-Step Method. Step Define ClassesOverview • A Real-World Identifier (“How do I tell one . . . from another?”) • A Definition (“What is a . . . ?”) • Sample Attributes and Behaviors (“What might I need to know about a . . .?” or “What can happen to a . . .?”) Each Candidate Class must undergo three checks:

  21. 9.2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier • Objects have Identity, • So they are distinct from each other, • And there is usually some way to tell them apart. • How do we tell one Student from another? - Different names - won’t do, not unique. - Also, names and such are too sensitive to errors • Punctuation and case • Spelling and spacing - Different faces - scanning technology not yet good enough

  22. 9.2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier Some Examples of Identifiers: • Student No. • Customer No. • Account No. • Licence No. • Serial No. • Product Code • Category Code • Vendor ID • Employee No. • Building ID • Street Name • City Name • State/Province ID • Vehicle ID No. (VIN) • Inventory No. • Room No. • Legal Description (Land) • Policy No.

  23. 9.2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier • So we try to find a unique identifier for our Candidate Class. • If we can’t, then it’s definitely not a class. • If we eventually do find one, then we move on to the next test, Question 2: The Definition . . .

  24. 9.2. The KRB Seven-Step Method. Step Define ClassesQuestion 2: The DefinitionThis part has four goals: • Documentthe users’ language and jargon • So we can learn about their business, • And document it for those who may follow us. • Produce a “Dictionary” to which we shall refer often in the later steps. • By having the users formally define their own terms, they may resolve many misunderstandings, ambiguities and unexamined assumptions. • Finally, contribute to our decision whether or not this Candidate Class is significant for our project.

  25. 9.2. The KRB Seven-Step Method. Step Define ClassesQuestion 2: The Definition God gave us two ears and one mouth . . .

  26. 9.2. The KRB Seven-Step Method. Step Define ClassesQuestion 2: The Definition • Your Recording Analyst must have both A Dictionaryand A Thesaurus during this process. • The identifier and the definition are usually enough to tell if this is a class for us, • But you may need to go to the third question, Sample Attributes and Behaviors . . .

  27. 9.2. The KRB Seven-Step Method. Step Define ClassesQuestion 3: Sample Attributes and Behaviors • Ask the users, • “What might you need to know about a Student?” • They’ll come up with a few things: • The name. • Age • Address • Etc. • If these attributes exist, • Then it follows that there must be a class to attach them to!

  28. 9.2. The KRB Seven-Step Method. Step Define ClassesQuestion 3: Sample Attributes and Behaviors • Similarly, you may ask the users, • “What can a Student do?” • Or, “What kind of things can happen to a Student?” • Again, they will come up with a few things: • He registers. • She changes her address. • Etc. • If these behaviors exist, then it also follows that there must be a class to attach them to!

  29. 9.2. The KRB Seven-Step Method. Step Define ClassesQuestion 3: Sample Attributes and Behaviors • Once all of your definitions have been done, you are ready to move to Step 3: Establish Associations. • Be prepared, however, to revisit the definition step many times, • To clarify the classes you have found, • And to define classes that you missed, and that you discover in the later steps. • And now, Step 3: Establish Associations . . .

  30. 9.2. The KRB Seven-Step Method. Step  Candidate Classes Step  Define Classes Step Establish Associations Step  Expand Many-to-Many Associations Step  Attributes Step  Normalization Step  Operations (i.e., Behavior)

  31. 9.2. The KRB Seven-Step Method. Step Establish Associations • An association is an interactionbetween instances of two classes, • Represented by a verb. • The ones we want are those that describe things that happen in the users’ business. • We need a sentence that goes “Object verb Object” • And makes sense in the users’ world.

  32. 9.2. The KRB Seven-Step Method. Step Establish Associations • There are two important parts to this sentence: The Verb, and The Multiplicity.

  33. 9.2. The KRB Seven-Step Method. Step Establish Associations • When A Customer buysa Product, • We hope he buys many of them! • And when a Product is sold to a Customer, we hope it is sold to manyCustomers. • So in this particular business, • The Customer-to-Product association is Many-to-Many, or M:M

  34. 9.2. The KRB Seven-Step Method. Step Establish Associations 1 * Customer *A/c No. Name Address Phone No. Balance Product *Prod No. Description Unit Price Qty in Stock buys * * * = “many”

  35. 9.2. The KRB Seven-Step Method. Step Establish Associations • “What does a Teacher DOto a Course?” • A Teacher teachesa Course. • How many? • A Teacher teaches a lot of courses. • But how many teachers teach a given course? Only one! • Which this time gives us a One-to-Many, or 1:M

  36. 9.2. The KRB Seven-Step Method. Step Establish Associations Teacher Course teaches *Employee No. Name Age Sex Salary *Course No. *Date Room No. Max Enrol * 1 * = “many”

  37. 9.2. The KRB Seven-Step Method. Step Establish Associations So this gives us the definition: Multiplicity is the number of instances of each class that can participate in the association.

  38. 9.2. The KRB Seven-Step Method. Step Establish Associations • And we must be careful not to miss any potential associations! • We must check each class against every other class, and each time ask: • “What does one of these DO to one of those?” • If there is an answer, we have an association, • And we must then find the multiplicity.

  39. 9.2. The KRB Seven-Step Method. Step Establish Associations • If you have four classes in your model, • That means you must check 8 possible associations • (there are 16 ways of combining 2 at a time out of 4 things). • If, as is more likely, you have something like 40 classes, • Then you must check 800 possibilities! Sounds impossible? It can be done . . .

  40. 9.2. The KRB Seven-Step Method. Step Establish Associations Warehouse Customer Product Invoice Vendor Bin Customer Product Vendor Invoice Bin Warehouse Either use a grid chart with all the classes listed down the side and also listed again along the top: X X X X X X X X X X X X X X X X X X

  41. 9.2. The KRB Seven-Step Method. Step Establish Associations Customer Product Vendor Invoice Bin Warehouse OR • Draw a line against the list of classes, each time you check out a possibility. • This way you check out each class against every classbelow it in the list.

  42. 9.2. The KRB Seven-Step Method. Step Establish Associations Then, once we have the associations in place, there is something we must do to all of the M:M associations in the model . . .

  43. 9.2. The KRB Seven-Step Method. Step  Candidate Classes Step  Define Classes Step  Establish Associations Step Expand Many-to-Many Associations Step  Attributes Step  Normalization Step  Operations (i.e., Behavior)

  44. 9.2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Take a look at this card-and-string database: Yo Pencil Ko Notebook Slo Thesaurus Mo Dictionary Donuts Jo Bo Coffee

  45. 9.2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations • This will allow us to do sales reports by either: • Pulling a Customer card, and the strings will bring all the relevant Product cards, • Or vice-versa. • But there are problems . . . Yo Pencil Ko Notebook Slo Thesaurus Mo Dictionary Donuts Jo Bo Coffee

  46. 9.2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations And, The data is recorded in two places, which is not good design, since it will get out of step (Murphy’s Law) Yo Pencil Bo Ko Notebook Donuts Slo Slo Donuts Notebook Thesaurus Jo Mo Dictionary Jo Jo Donuts Coffee Donuts Dictionary Thesaurus Jo Slo Ko Coffee Bo Jo Pencil

  47. 9.2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Not only that, but where would we write the date, quantity and selling price for each sale? On the strings, perhaps? Pencil Bo Yo Notebook Ko Donuts Slo Thesaurus Jo Slo Donuts Notebook Dictionary Mo Jo Donuts Jo Jo Slo Ko Coffee Donuts Dictionary Thesaurus Coffee Jo Bo Pencil

  48. 9.2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations We replace each string with a card and two strings: Bo Pencils 10 Monday $.49 Yo Pencil Notebook Ko This allows us to write the details on the card in the middle Thesaurus Slo Mo Dictionary Jo Donuts Bo Coffee

  49. 9.2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Bo Pencils 10 Monday $.49 Yo Pencil Ko Donuts Notebook Ko 12 Tuesday $1.49 Slo Notebook Thesaurus Slo 1 Friday $2.00 Slo Donuts Mo 4 Tuesday $.49 Dictionary Jo Thesaurus Jo Donuts 4 Thursday $2.49 Jo Dictionary 1 Wednesday $1.19 Bo Coffee Jo Donuts 3 Tuesday $.39 Jo Coffee 3 Tuesday $.59

  50. 9.2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations This card-and-string database can be modeled with a class diagram, First as a M:M. . .

More Related