Скачать презентацию An Introduction to Object-Oriented Analysis Objects and UML Скачать презентацию An Introduction to Object-Oriented Analysis Objects and UML

65a051a4416c152129b0b23bf8d0f491.ppt

  • Количество слайдов: 178

An Introduction to Object-Oriented Analysis Objects and UML in plain English. Chapter 9: Finding An Introduction to Object-Oriented Analysis Objects and UML in plain English. Chapter 9: Finding Objects and Classes in the Real World Based on the book by David William Brown John Wiley & Sons, ISBN 0471371378 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 1

Copyright 8 2002 Flying Kiwi Productions All rights reserved. This slide presentation is based Copyright 8 2002 Flying Kiwi Productions All rights reserved. This slide presentation is based on “An Introduction to Object. Oriented Analysis; Objects and UML in Plain English, ” by David William Brown, Wiley, ISBN 0471371378, “The Book. ” Permission is hereby granted to copy, modify or excerpt all or any part of this slide presentation, provided it is solely for use with courses, seminars or other presentations or productions where a copy of The Book is purchased by or for each and every participant or recipient. An instructor guide is available from the publisher for such presentations. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 2

Chapter 9: Finding Objects and Classes in the Real World Outline: 9. 1. 9. Chapter 9: Finding Objects and Classes in the Real World Outline: 9. 1. 9. 2. 9. 3. 9. 4. 9. 5. The Importance of This Step. The KRB Seven-Step Method. Is It A Class or Is It An Attribute? Finding Structures. Adapting the Method. Let’s check these 5 in detail. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 3

Chapter 9: Finding Objects and Classes in the Real World 9. 1. The Importance Chapter 9: Finding Objects and Classes in the Real World 9. 1. The Importance of This Step. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 4

9. 1. The Importance of This Step. l The concept of class is one 9. 1. The Importance of This Step. l The concept of class is one of the key things in the Object-Oriented world, l So one of the first steps is to find all the classes, l l All the classes, That matter for this project. l How do we know when we have them at least close enough)? all (or Read on. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 5

9. 1. The Importance of This Step. l First we must be user-driven, l 9. 1. The Importance of This Step. l First we must be user-driven, l That is, we must take the attitude that the users know what we need to know l To get our job done properly. l They just don’t know that they know it! l What follows is a reliable set of techniques for working with the users l To get from them what we need, l Documented the way we need it, l To build for them the right software, That they truly need. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 6

9. 1. The Importance of This Step. Remember how Jacobson (Yah-cob-son) classified the object 9. 1. The Importance of This Step. Remember how Jacobson (Yah-cob-son) classified the object classes: Jacobson’s Three Types n Entity Objects Concrete objects s Conceptual objects s Event and State objects s n Interface Objects n Control Objects Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 7

9. 1. The Importance of This Step. Jacobson’s Three Types l Entity Objects - 9. 1. The Importance of This Step. Jacobson’s Three Types l Entity Objects - things in the users’ real world n Concrete objects - Employee, Product, Tool, etc. n Conceptual objects - Corporation, strategy, membership, approval, etc. n Event and State objects - Purchase, delivery, arrival, ownership, status, etc. l Interface Objects - To encapsulate the details of GUIs, communication protocols, and the like. l Control Objects - To carry complex methods that don’t have a class they obviously belong in. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 8

9. 1. The Importance of This Step. The Class Diagram is the foundation for 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. Copyright If not, you don’t 8 2002 Flying Kiwi Productions Inc. [email protected] com 9

9. 1. The Importance of This Step. “There’s never time to do it right, 9. 1. The Importance of This Step. “There’s never time to do it right, But always time to do it over!” l Time and effort spent up front will pay off later l In: reduced errors, s early discovery of errors, and s ease and cost of correcting errors. s l This is especially true of time, care and effort spent on the human side of the process. l Remember The difference between a great systems analyst and a merely good one is in their People Skills. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 10

9. 1. The Importance of This Step. Following is a “recipe” for finding all 9. 1. The Importance of This Step. Following is a “recipe” for finding all the classes that are important to your project. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 11

Chapter 9: Finding Objects and Classes in the Real World 9. 1. The Importance 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. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 12

Chapter 9: Finding Objects and Classes in the Real World 9. 2. The KRB Chapter 9: Finding Objects and Classes in the Real World 9. 2. The KRB Seven-Step Method. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 13

9. 2. The KRB Seven-Step Method. l This is not a formal “Methodology”; l 9. 2. The KRB Seven-Step Method. l This is not a formal “Methodology”; l More like a handy set of steps, l That can be adapted for use with almost any methodology. l They work as is, for practically anybody. Once you’ve tried them as described, feel free to customize them to your needs and your style. And the KRB Seven Steps are. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 14

9. 2. The KRB Seven-Step Method. Step Candidate Classes Step Define Classes Step Establish 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) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 15

9. 2. The KRB Seven-Step Method Overview Step Candidate Classes n Several ways to 9. 2. The KRB Seven-Step Method Overview Step Candidate Classes n Several ways to find nouns that might turn out to be names of classes that matter to your project. Step Define Classes n Here we check for the meaning the users attach to each noun, and decide whether it is important for this project. Step Establish Associations n Checking how these things interact gives us a picture of the pathways that exist throughout the data Step Expand Many-to-Many Associations n An essential step that generates much discussion and more classes. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 16

9. 2. The KRB Seven-Step Method Overview Step Attributes n We list out all 9. 2. The KRB Seven-Step Method Overview Step Attributes n We list out all the data fields the users need to keep about each thing (i. e. , about each type of entity). Step Normalization n A technical consideration, with a different relevance in the object paradigm. This step is done behind closed doors without the users. Step Operations (i. e. , Behavior) n This is the additional step that distinguishes objects from entities and earlier models. This part is the subject of Chapters 10 and 11. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 17

9. 2. The KRB Seven-Step Method. Step Candidate Classes Copyright 8 2002 Flying Kiwi 9. 2. The KRB Seven-Step Method. Step Candidate Classes Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 18

9. 2. The KRB Seven-Step Method. Step Candidate Classes Definition: Candidate Classes: Nouns that 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. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 19

9. 2. The KRB Seven-Step Method. Step Candidate Classes: At this stage, all we 9. 2. The KRB Seven-Step Method. Step Candidate Classes: At this stage, all we want is names for possible classes. Later we will define the classes in detail. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 20

9. 2. The KRB Seven-Step Method. Step Candidate Classes Entity Classes l Things in 9. 2. The KRB Seven-Step Method. Step Candidate Classes Entity Classes l Things in the world of the users. l These are the four most popular methods for this step: Client Interviews n Nouns from the Documentation n Brainstorming n Delphi: Brainstorming in Slow Motion n Now these four methods in detail. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 21

9. 2. The KRB Seven-Step Method. Step Candidate Classes 1. Client Interviews l Good 9. 2. The KRB Seven-Step Method. Step Candidate Classes 1. Client Interviews l Good for busy senior executives. l Adapt the group methods (Brainstorming, etc. ) to individual or small-group setting. l Possibly interview them first, then build the model away from the users. l Bring the model back to the users regularly for feedback and input. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 22

9. 2. The KRB Seven-Step Method. Step Candidate Classes 2. Nouns from the Documentation 9. 2. The KRB Seven-Step Method. Step Candidate Classes 2. Nouns from the Documentation l Use this idea by itself, or with the others. l You need nouns. l Start with any or all of these documents: n Systems Request Document n Change Request Document n The mandate, mission, strategic plan, etc. for the users’ business. n Any document that describes that portion of the users’ business which you are about to model. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 23

9. 2. The KRB Seven-Step Method. Step Candidate Classes 2. Nouns from the Documentation 9. 2. The KRB Seven-Step Method. Step Candidate Classes 2. Nouns from the Documentation Also go through your own documents: l Your Requirements Models l Project Scope l Context Diagram l Use Cases l Interface descriptions l And any other document that you think might be a fruitful source of nouns concerned in your users’ business. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 24

9. 2. The KRB Seven-Step Method. Step Candidate Classes 2. Nouns from the Documentation 9. 2. The KRB Seven-Step Method. Step Candidate Classes 2. Nouns from the Documentation l Go through all these documents, l Pick out Nouns l That you think might be objects or classes. l Choose everything that might fit, l You will be evaluating them all in Step 2: Definitions. “If in doubt, bring it out!” Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 25

9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming l While all 9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming l While all agree that Use Cases are valuable, some argue that they focus too much on the system, i. e. , on the current problem and the solution we’re about to build. l But to provide our software with true resilience to change we need to model the users’ business and their data, Independent of any use the data may be put to. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 26

9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming Our Class Diagram 9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming Our Class Diagram must be based l Not on the needs of the current project, l But on the total data users’ business area. requirements of the The brainstorming method does just that. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 27

9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming Definition: l Formal 9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming Definition: l Formal Brainstorming takes place in two distinct phases. generating ideas, l and the second phase is for evaluating l The first phase is for those ideas. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 28

9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming First Phase l 9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming First Phase l Generate a flow of ideas l Doesn't matter how silly or trivial, l If it’s an idea, we want it! l Doesn’t matter how good the idea is or isn’t. l There is no such thing as a bad idea! l Every idea matters. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 29

9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming First Phase We 9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming First Phase We need every idea to be put out there, l Even the ones where the owner might think it’s a dumb idea! l Two things that can happen to such an idea: n (S)he may be surprised at just how important it turns out to be, or n It may stimulate someone else to come up with an important idea. There is no such thing as a dumb idea!! Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 30

9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming First Phase l 9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming First Phase l l l l No evaluation of ideas in the First Phase. No “Oh, I don’t think so!” No “Forget it!” No “There goes Joe again!” No “Joe you have some weird ideas!” No groans, No comments, No raised eyebrows, Nothing!! Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 31

9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming First Phase l 9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming First Phase l Every idea goes up on the whiteboard. l Recognize each person’s contribution n n “Yes” “OK!” “Uh-huh” “Good” Or just an encouraging grunt. l Read “the Outhouse” p 284 for an example. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 32

9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming Second Phase l 9. 2. The KRB Seven-Step Method. Step Candidate Classes 3. Brainstorming Second Phase l The second phase is the careful evaluation of each idea l To see if it should be kept. l This we do in our KRB Step 2: Definitions. For the moment, the last of our four methods to generate candidate class names. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 33

9. 2. The KRB Seven-Step Method. Step Candidate Classes 4. Delphi Method: “Brainstorming in 9. 2. The KRB Seven-Step Method. Step Candidate Classes 4. Delphi Method: “Brainstorming in Slow Motion” or alternatively, “Brainstorming by Mail” l Good for busy senior users. l Can be done by memo or face-to-face, l One-on-one or in small groups. l A very flexible method. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 34

9. 2. The KRB Seven-Step Method. Step Candidate Classes 4. Delphi Method: Brainstorming in 9. 2. The KRB Seven-Step Method. Step Candidate Classes 4. Delphi Method: Brainstorming in Slow Motion l Meet with or memo each person, l Get them to write a list of candidate classes. (You will need to explain it as on the previous slides. ) l Then you combine all the responses, l Come up with a composite list, l Circulate this complete list to all, for review and inspired additions. l Repeat as you judge necessary. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 35

9. 2. The KRB Seven-Step Method. Step Candidate Classes You have seen the four 9. 2. The KRB Seven-Step Method. Step Candidate Classes You have seen the four methods for finding Entity Classes, Client Interviews n Nouns from the Documentation n Brainstorming n Delphi: Brainstorming in Slow Motion n l Now let’s finish by looking at Interface and Control Classes. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 36

9. 2. The KRB Seven-Step Method. Step Candidate Classes Interface Classes l User Interfaces: 9. 2. The KRB Seven-Step Method. Step Candidate Classes Interface Classes l User Interfaces: n Your classes will be defined by your GUI tool. l Data Communications Interfaces: If you buy a communications class library, your classes are already defined for you. n The published comm protocol should be filed with or referred from your project documentation. n l Real-world systems to control or monitor: Industrial Processes, etc. n Define a single-instance class to represent the external system. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com n 37

9. 2. The KRB Seven-Step Method. Step Candidate Classes Control Classes l Will mostly 9. 2. The KRB Seven-Step Method. Step Candidate Classes Control Classes l Will mostly be discovered in the Design Phase of the OODLC. l As with anything else, if the topic arises earlier during the Analysis Phase, l Use you judgement; l Either do it now, or l Make serious notes to ensure it gets done later. (Don’t ever miss it!) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 38

9. 2. The KRB Seven-Step Method. Step Candidate Classes So we have found all 9. 2. The KRB Seven-Step Method. Step Candidate Classes So we have found all the nouns, i. e. the names of the candidate classes. Now let’s define and evaluate them in KRB Step 2. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 39

9. 2. The KRB Seven-Step Method. Step Candidate Classes Step Define Classes Step Establish 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) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 40

9. 2. The KRB Seven-Step Method. Step Define Classes Copyright 8 2002 Flying Kiwi 9. 2. The KRB Seven-Step Method. Step Define Classes Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 41

9. 2. The KRB Seven-Step Method. Step Define Classes Overview Each Candidate Class must 9. 2. The KRB Seven-Step Method. Step Define Classes Overview Each Candidate Class must undergo three checks: l A Real-World Identifier (“How do I tell one. . . from another? ”) l A Definition (“What is a. . . ? ”) l Sample Attributes and Behaviors (“What might I need to know about a. . . ? ” or “What can happen to a. . . ? ”) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 42

9. 2. The KRB Seven-Step Method. Step Define Classes Overview l There is no 9. 2. The KRB Seven-Step Method. Step Define Classes Overview l There is no necessary sequence to these questions, l But the order they are shown here works very well. l These questions will guide thinking and discussion, l As you and the users decide what the classes should be, l And whether they belong in this project. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 43

9. 2. The KRB Seven-Step Method. Step Define Classes Overview l There is no 9. 2. The KRB Seven-Step Method. Step Define Classes Overview l There is no rigorous way to do this, l It often has to be a judgement call, l Made by your users, with your leadership. users l Though it has an obvious technology underlying it, l Object modeling is definitely an rather than a science. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com art, 44

9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier 9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier l l 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 9 Punctuation and case 9 Spelling and spacing - Different faces - scanning technology not yet good enough Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 45

9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier 9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier l If Student is an important class for our project, l Then its instances have identity, l. But not the other way around! l But knowing it has an identifier, even if not truly unique in the real world, helps us make the decision. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 46

9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier 9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier l Were you unique before you were born? Of course you were! l When did you get your name? After you were born! l Note that identifiers do not confer or grant identity, l They merely document identity that exists already. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 47

9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier 9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier Some Examples of Identifiers: l l l l l Student No. Customer No. Account No. Licence No. Serial No. Product Code Category Code Vendor ID Employee No. Copyright 8 2002 Flying Kiwi Productions Inc. l l l l l Building ID Street Name City Name State/Province ID Vehicle ID No. (VIN) Inventory No. Room No. Legal Description (Land) Policy No. [email protected] com 48

9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier 9. 2. The KRB Seven-Step Method. Step Define Classes Question 1: A Real-World Identifier l So we try to find a unique identifier for our Candidate Class. l If we can’t, then it’s definitely not a class. l If we eventually do find one, then we move on to the next test, Question 2: The Definition. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 49

9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition This 9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition This part has four goals: l Document the users’ language and jargon So we can learn about their business, n And document it for those who may follow us. n l Produce a “Dictionary” to which we shall refer often in the later steps. l By having the users formally define their own terms, they may resolve many misunderstandings, ambiguities and unexamined assumptions l Finally, contribute to our decision whether or not this Candidate Class is significant for our project. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 50

9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition l 9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition l Ask the users, l “What is a Customer? ” l And work with them to lead them to a definition l That makes sense to them. l It must be their definition, l Not yours or mine! “Customer: A person, company, or other group who purchases widgets from XYZ Widget Co. ” Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 51

9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition l 9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition l Definitions must be proposed and examined for classes, l Even the most obvious ones. l Sometimes the “obvious” ones can surprise us ! l There will often be all several opinions l And you must lead the discussion towards resolving the different points of view. l An argument often means you need two classes instead of one, with different definitions. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 52

9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition l 9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition l Employee: A person who works at XYZ Widgets. l Sounds reasonable, but do we simply delete the records when (s)he quits? Try this: l Employee: A person who works, or has worked, at XYZ Widgets. l Better, and this will work for most businesses. l But you may find a company that wants prospective employees to be kept in the database! Try this: Employee: A person who works, has worked, or may in the future work at XYZ Widgets. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 53

9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition God 9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition God gave us two ears and one mouth. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 54

9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition l 9. 2. The KRB Seven-Step Method. Step Define Classes Question 2: The Definition l Your Recording Analyst must have both A Dictionary and A Thesaurus during this process. l The identifier and the definition are usually enough to tell if this is a class for us, l But you may need to go to the third question, Sample Attributes and Behaviors. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 55

9. 2. The KRB Seven-Step Method. Step Define Classes Question 3: Sample Attributes and 9. 2. The KRB Seven-Step Method. Step Define Classes Question 3: Sample Attributes and Behaviors l Ask the users, l “What might you need to know about a Student? ” l They’ll come up with a few things: The name. n Age n Address n Etc. n If these attributes exist, l Then it follows that there must be a class to attach them to! l Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 56

9. 2. The KRB Seven-Step Method. Step Define Classes Question 3: Sample Attributes and 9. 2. The KRB Seven-Step Method. Step Define Classes Question 3: Sample Attributes and Behaviors l Similarly, you may ask the users, l “What can a Student do? ” l Or, “What kind of things can happen to a Student? ” l Again, they will come up with a few things: n He registers. n He fails. n She changes her address. n Etc. l If these behaviors exist, then it also follows that there must be a class to attach them to! Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 57

9. 2. The KRB Seven-Step Method. Step Define Classes Question 3: Sample Attributes and 9. 2. The KRB Seven-Step Method. Step Define Classes Question 3: Sample Attributes and Behaviors l Once all of your definitions have been done, you are ready to move to Step 3: Establish Associations. l Be prepared, however, to revisit the definition step many times, l To clarify the classes you have found, l And to define classes that you missed, and that you discover in the later steps. l And now, Step 3: Establish Associations. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 58

9. 2. The KRB Seven-Step Method. Step Candidate Classes Step Define Classes Step Establish 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) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 59

9. 2. The KRB Seven-Step Method. Step Establish Associations Copyright 8 2002 Flying Kiwi 9. 2. The KRB Seven-Step Method. Step Establish Associations Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 60

9. 2. The KRB Seven-Step Method. Step Establish Associations Here we ask the questions: 9. 2. The KRB Seven-Step Method. Step Establish Associations Here we ask the questions: l “What does a Student DO to a Course? ” l Enrols in it, of course. l “What does a Customer DO to a Product? ” l A Customer buys a Product. l “What does a Teacher DO to a Course? ” l A Teacher teaches a Course. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 61

9. 2. The KRB Seven-Step Method. Step Establish Associations l An association is an 9. 2. The KRB Seven-Step Method. Step Establish Associations l An association is an interaction between instances of two classes, l Represented by a verb. l The ones we want are those that describe things that happen in the users’ business. l We need a sentence that goes “Object verb Object” l And makes sense in the users’ world. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 62

9. 2. The KRB Seven-Step Method. Step Establish Associations l There are two important 9. 2. The KRB Seven-Step Method. Step Establish Associations l There are two important parts to this sentence: The Verb, and The Multiplicity. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 63

9. 2. The KRB Seven-Step Method. Step Establish Associations When we ask the question: 9. 2. The KRB Seven-Step Method. Step Establish Associations When we ask the question: l “What does a Student DO to a Course? ” and answer “Why, Enrolls in it, of course!” l The next thing to ask is: “How many courses does a Student enrol in? ” Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 64

9. 2. The KRB Seven-Step Method. Step Establish Associations l The key thing is, 9. 2. The KRB Seven-Step Method. Step Establish Associations l The key thing is, Is (s)he limited to one course, or can (s)he take a whole bunch? l i. e. , Is it One, or is it Many? Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 65

9. 2. The KRB Seven-Step Method. Step Establish Associations l When A Customer buys 9. 2. The KRB Seven-Step Method. Step Establish Associations l When A Customer buys a Product, l We hope he buys many of them! l And when a Product is sold to a Customer, we hope it is sold to many Customers. l So in this particular business, l The Customer-to-Product association is Many-to-Many, or M: M Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 66

9. 2. The KRB Seven-Step Method. Step Establish Associations Product *Prod No. Description Unit 9. 2. The KRB Seven-Step Method. Step Establish Associations Product *Prod No. Description Unit Price Qty in Stock buys * * Customer *A/c No. Name Address Phone No. Balance * = “many” Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 67

9. 2. The KRB Seven-Step Method. Step Establish Associations l “What does a Teacher 9. 2. The KRB Seven-Step Method. Step Establish Associations l “What does a Teacher DO to a Course? ” l A Teacher teaches a Course. l How many? l A Teacher teaches a lot of courses. l But how many teachers teach a given course? Only one! l Which this time gives us a One-to-Many, or 1: M Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 68

9. 2. The KRB Seven-Step Method. Step Establish Associations Teacher *Employee No. Name Age 9. 2. The KRB Seven-Step Method. Step Establish Associations Teacher *Employee No. Name Age Sex Salary Course teaches * 1 *Course No. *Date Room No. Max Enrol * = “many” Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 69

9. 2. The KRB Seven-Step Method. Step Establish Associations So this gives us the 9. 2. The KRB Seven-Step Method. Step Establish Associations So this gives us the definition: Multiplicity is the number of instances Copyright of each class that can participate in the association. 8 2002 Flying Kiwi Productions Inc. [email protected] com 70

9. 2. The KRB Seven-Step Method. Step Establish Associations l And we must be 9. 2. The KRB Seven-Step Method. Step Establish Associations l And we must be careful not to miss any potential associations! l We must check each class against every other class, and each time ask: l “What does one of these DO to one of those? ” l If there is an answer, we have an association, l And we must then find the multiplicity. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 71

9. 2. The KRB Seven-Step Method. Step Establish Associations l If you have four 9. 2. The KRB Seven-Step Method. Step Establish Associations l If you have four classes in your model, l That means you must check 8 possible associations n (there are 16 ways of combining 2 at a time out of 4 things). l If, as is more likely, you have something like 40 classes, l Then you must check 800 possibilities! Sounds impossible? It can be done. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 72

9. 2. The KRB Seven-Step Method. Step Establish Associations Warehouse Bin Invoice Vendor Product 9. 2. The KRB Seven-Step Method. Step Establish Associations Warehouse Bin Invoice Vendor Product Customer Either use a grid chart with all the classes listed down the side and also listed again along the top: Customer X Product X Vendor X X X X Invoice Bin Warehouse Copyright 8 2002 Flying Kiwi Productions Inc. X X [email protected] com 73

9. 2. The KRB Seven-Step Method. Step Establish Associations l Check off the empty 9. 2. The KRB Seven-Step Method. Step Establish Associations l Check off the empty squares as you check out each possible relationship. l The ‘X’s are squares you don’t need to do, since that would mean doing every one twice! l Or you may prefer to use the method shown in the book (pgs 295 - 297). . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 74

9. 2. The KRB Seven-Step Method. Step Establish Associations Customer Product Vendor Invoice Bin 9. 2. The KRB Seven-Step Method. Step Establish Associations Customer Product Vendor Invoice Bin Warehouse l Draw a line against the list of classes, each time you check out a possibility. l This way you check out each class against every class below Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com it in the list. 75

9. 2. The KRB Seven-Step Method. Step Establish Associations l As you’re working through 9. 2. The KRB Seven-Step Method. Step Establish Associations l As you’re working through this with your users, l Whenever difficulties arise, l There is one thing to do always: Refer back to your definitions!! This is one of the most important reasons for those definitions. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 76

9. 2. The KRB Seven-Step Method. Step Establish Associations Then, once we have the 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. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 77

9. 2. The KRB Seven-Step Method. Step Candidate Classes Step Define Classes Step Establish 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) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 78

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Copyright 8 2002 Flying 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 79

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Take a look at 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Take a look at this card-and-string database: Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 80

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Take a look at 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 Copyright 8 2002 Flying Kiwi Productions Inc. Coffee [email protected]. com 81

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations l This will allow 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations l This will allow us to do sales reports by either: l Pulling a Customer card, and the strings will bring all the relevant Product cards, l Or vice-versa. l But there are problems. . . Yo Pencil Ko Notebook Slo Mo Jo Bo Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com Thesaurus Dictionary Donuts Coffee 82

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations More realistically, we could 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations More realistically, we could perhaps write on the cards instead of using strings: Yo Pencil As you can easily see Notebook on Jo’s card, we are Slo likely to run out of Thesaurus Jo room! Dictionary Jo Ko Donuts Slo Donuts Notebook Mo Jo Coffee Donuts Dictionary Thesaurus Bo Copyright Bo Pencil 8 2002 Flying Kiwi Productions Inc. Coffee [email protected] com Jo Slo Ko Jo 83

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations And, Yo The data 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations And, Yo The data is recorded in two places, Pencil Bo which is not good design, Notebook Slo Donuts since it will get Thesaurus Jo Notebook Ko Donuts Slo out of step Mo Dictionary Jo (Murphy’s Law) Jo Coffee Donuts Dictionary Thesaurus Bo Pencil Copyright 8 2002 Flying Kiwi Productions Inc. Coffee [email protected] com Jo Slo Ko Jo 84

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Not only that, but 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? Yo Pencil Bo On the strings, perhaps? Notebook Ko Donuts Slo Thesaurus Donuts Notebook Jo Dictionary Jo Mo Donuts Jo Coffee Donuts Dictionary Thesaurus Bo Copyright Slo Pencil 8 2002 Flying Kiwi Productions Inc. Coffee [email protected] com Jo Slo Ko Jo 85

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations There is a way 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations There is a way out, That allows us a place to write the Sale data, And also makes sure we don’t run out of room writing on the cards. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 86

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations We replace each string 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations We replace each string with a card and two strings: Yo Pencil Notebook Ko Thesaurus Slo Mo Dictionary Jo Donuts Bo Copyright 8 2002 Flying Kiwi Productions Inc. Coffee [email protected] com 87

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations We replace each string 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 Yo Pencil Notebook Ko Thesaurus Slo Mo Dictionary Jo Donuts Bo Copyright 8 2002 Flying Kiwi Productions Inc. Coffee [email protected] com 88

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations We replace each string 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 Yo Pencil Notebook Ko Thesaurus Slo Mo Dictionary Jo Donuts Bo Copyright 8 2002 Flying Kiwi Productions Inc. Coffee [email protected] com 89

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations We replace each string 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 Yo Pencil Notebook Ko This allows us to write the details on the card in the middle Slo Mo Jo Bo Copyright 8 2002 Flying Kiwi Productions Inc. Thesaurus Dictionary Donuts Coffee [email protected] com 90

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations We replace each string 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 Slo Mo Jo Bo Copyright 8 2002 Flying Kiwi Productions Inc. Thesaurus Dictionary Donuts Coffee [email protected] com 91

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Bo Pencils 10 Monday 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Bo Pencils 10 Monday $. 49 Yo Pencil Notebook Ko Now let’s do the rest: Slo Mo Jo Dictionary Donuts Bo Copyright Thesaurus 8 2002 Flying Kiwi Productions Inc. Coffee fly[email protected] com 92

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Bo Pencils 10 Monday 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Bo Pencils 10 Monday $. 49 Yo Pencil Ko Donuts Ko Notebook 12 Tuesday $1. 49 Slo Notebook Slo Thesaurus 1 Friday $2. 00 Slo Donuts 4 Tuesday $. 49 Mo Jo Donuts Bo Copyright Dictionary 8 2002 Flying Kiwi Productions Inc. Coffee [email protected] com 93

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Bo Pencils 10 Monday 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Bo Pencils 10 Monday $. 49 Yo Pencil Ko Donuts Ko Notebook 12 Tuesday $1. 49 Slo Notebook Slo Thesaurus 1 Friday $2. 00 Slo Donuts 4 Tuesday $. 49 Mo Jo Thesaurus Jo 4 Thursday $2. 49 Dictionary Donuts Jo Dictionary Bo 1 Wednesday $1. 19 Jo Donuts Coffee 3 Tuesday $. 39 Jo Coffee 3 Tuesday $. 59 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 94

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations This card-and-string database can 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. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 95

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Customer *Name Address Phone 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Customer *Name Address Phone No. Balance buys * * Product *Description Unit Price Qty in Stock “Customer buys Product” Yo Ko Slo Mo Jo Bo Copyright 8 2002 Flying Kiwi Productions Inc. Bo Pencils 10 Monday $. 49 Ko Donuts 12 Tuesday $1. 49 Slo Notebook 1 Friday $2. 00 Slo Donuts 4 Tuesday $. 49 Jo Thesaurus 4 Thursday $2. 49 Jo Dictionary 1 Wednesday $1. 19 Jo Donuts 3 Tuesday $. 39 Jo Coffee 3 Tuesday $. 59 [email protected] com Pencil Notebook Thesaurus Dictionary Donuts Coffee 96

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Which then becomes a 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Which then becomes a pair of 1: M. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 97

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Customer *Name Address Phone 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Customer *Name Address Phone No. Balance is involved in 1 * Sale *Name *Description Qty Sold Actual Price Product *Description Unit Price Qty in Stock has * 1 Check the strings - the M: M is now 2 x 1: M !! Yo Ko Slo Mo Jo Bo Copyright 8 2002 Flying Kiwi Productions Inc. Bo Pencils 10 Monday $. 49 Ko Donuts 12 Tuesday $1. 49 Slo Notebook 1 Friday $2. 00 Slo Donuts 4 Tuesday $. 49 Jo Thesaurus 4 Thursday $2. 49 Jo Dictionary 1 Wednesday $1. 19 Jo Donuts 3 Tuesday $. 39 Jo Coffee 3 Tuesday $. 59 [email protected] com Pencil Notebook Thesaurus Dictionary Donuts Coffee 98

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations l The Sale class 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations l The Sale class we have discovered in the middle is an Associative Class, or sometimes an Intersection Class. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 99

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations And here is the 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations And here is the principle: A M: M relationship always breaks out into a pair of 1: M, with a new class in the middle, and the “many” ends against the new class. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 100

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations There is an interesting 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations There is an interesting variation. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 101

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Collapsing Events: When you 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Collapsing Events: When you have a triangle of events like this, Very often one of them is redundant, buys Customer * * * is sold by buys from * Copyright 8 2002 Flying Kiwi Productions Inc. Salesperson Product * * [email protected] com 102

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Collapsing Events: And often 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations Collapsing Events: And often they will collapse into a single Intersection Class like Sale here. Is involved in Customer Product has 1 * Sale * * 1 1 Makes Salesperson Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 103

9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations And that concludes the 9. 2. The KRB Seven-Step Method. Step Expand Many-to-Many Associations And that concludes the Association section. There’s just three more steps, Beginning with The Attributes. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 104

9. 2. The KRB Seven-Step Method. Step Candidate Classes Step Define Classes Step Establish 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) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 105

9. 2. The KRB Seven-Step Method. Step Attributes Copyright 8 2002 Flying Kiwi Productions 9. 2. The KRB Seven-Step Method. Step Attributes Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 106

9. 2. The KRB Seven-Step Method. Step Attributes l With the users, list all 9. 2. The KRB Seven-Step Method. Step Attributes l With the users, list all the attributes you can think of for each class on your diagram. l For a small model, list them inside the boxes on the diagram. l If there’s too many for this, list them separately as part of the textual documentation that goes with the diagram. Then we are into the next step, Normalization. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 107

9. 2. The KRB Seven-Step Method. Step Candidate Classes Step Define Classes Step Establish 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) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 108

9. 2. The KRB Seven-Step Method. Step Normalization Copyright 8 2002 Flying Kiwi Productions 9. 2. The KRB Seven-Step Method. Step Normalization Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 109

9. 2. The KRB Seven-Step Method. Step Normalization l. This is a topic that 9. 2. The KRB Seven-Step Method. Step Normalization l. This is a topic that has largely been dropped in the move from relational databases to object technology. l At the same time that objects came along, l So did the need to handle complex data types, l Such as graphics, sound, video, lists and BLOBs, l And these often violate the technical rules of Normalization. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 110

9. 2. The KRB Seven-Step Method. Step Normalization l. However, there is a basic 9. 2. The KRB Seven-Step Method. Step Normalization l. However, there is a basic principle that I call The “goal” or “essence” of Normalization, And that principle still applies in the object world. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 111

9. 2. The KRB Seven-Step Method. Step Normalization Let’s start with an example. Say 9. 2. The KRB Seven-Step Method. Step Normalization Let’s start with an example. Say you need a sales report something like this: Customer Catalog Unit No. Name Address No. Description Price Date 131 Jo Blo 13 May St 3 A 21 T-Shirt 179 Yo Yo 271 OK Ave 1 B 77 Sweats 212 Mu Mu 32 Saddle Rd 4 X 21 Pants. . . . 03/01/98 01/03/98 12/11/98. . . Copyright 8 2002 Flying Kiwi Productions Inc. 12. 49 15. 00 23. 47. . . [email protected] com Qty Sold Actual Price 45 12 5. . . 10. 00 15. 00 21. 00. . . Extended Price 450. 00 180. 00 105. 00. . . 112

9. 2. The KRB Seven-Step Method. Step Normalization l What the uninitiated (read “amateur”) 9. 2. The KRB Seven-Step Method. Step Normalization l What the uninitiated (read “amateur”) database amateur designer tends to do is to build a relational table that mimics this report. l That is, it has the same columns as this report. l In the object paradigm, the equivalent error would be to create a class with attributes that match the columns on the report. l But what would we call this class? l The best name would probably be something like “Sales” or “Sales Analysis. ” Copyright 8 2002 Flying Kiwi Productions Inc. But. . . [email protected] com 113

9. 2. The KRB Seven-Step Method. Step Normalization l. The problem is that we 9. 2. The KRB Seven-Step Method. Step Normalization l. The problem is that we have three kinds of data in this report. l We have: Data that describes a Customer (Cust No. /Name/Address) Data that describes a Product (Cat No/Description/Unit Price) And data that describes a Sale (Date/Quantity/Actual and Extended Prices) l Compare this situation with all the earlier models we have looked at, l You’ll see that Customer, Product and Sale should each be a separate class. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 114

9. 2. The KRB Seven-Step Method. Step Normalization Customer *Name Address Phone No. Balance 9. 2. The KRB Seven-Step Method. Step Normalization Customer *Name Address Phone No. Balance is involved in 1 * Sale *Name *Description *Date Qty Sold Actual Price Ext. Price Product *Description Unit Price Qty in Stock has * 1 Like this! Yo Ko Slo Mo Jo Bo Copyright 8 2002 Flying Kiwi Productions Inc. Bo Pencils 10 Monday $. 49 Ko Donuts 12 Tuesday $1. 49 Slo Notebook 1 Friday $2. 00 Slo Donuts 4 Tuesday $. 49 Jo Thesaurus 4 Thursday $2. 49 Jo Dictionary 1 Wednesday $1. 19 Jo Donuts 3 Tuesday $. 39 Jo Coffee 3 Tuesday $. 59 [email protected] com Pencil Notebook Thesaurus Dictionary Donuts Coffee 115

9. 2. The KRB Seven-Step Method. Step Normalization l This “Normalized” arrangement is what 9. 2. The KRB Seven-Step Method. Step Normalization l This “Normalized” arrangement is what leads to the stability promised by Chen with both Entities and Objects! Objects l This structure allows our database to answer any query that could possibly be dreamed up against that data. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 116

9. 2. The KRB Seven-Step Method. Step Normalization l The “Un-normalized” structure that mimicked 9. 2. The KRB Seven-Step Method. Step Normalization l The “Un-normalized” structure that mimicked the report will have problems , down the line a few months or years, l Attempting to answer queries that the database designer did not foresee l What I refer to as: “That most dreaded of all database phenomena, Unanticipated Queries” Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 117

9. 2. The KRB Seven-Step Method. Step Normalization So it is fair to state 9. 2. The KRB Seven-Step Method. Step Normalization So it is fair to state that The goal of Normalization is to get every attribute attached to the class of objects that it truly describes. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 118

9. 2. The KRB Seven-Step Method. Step Normalization Let’s say that again. . . 9. 2. The KRB Seven-Step Method. Step Normalization Let’s say that again. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 119

9. 2. The KRB Seven-Step Method. Step Normalization What Normalization is for is to 9. 2. The KRB Seven-Step Method. Step Normalization What Normalization is for is to make sure that each class carries only the attributes that actually describe that kind of object. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 120

9. 2. The KRB Seven-Step Method. Step Normalization l. This is presented as the 9. 2. The KRB Seven-Step Method. Step Normalization l. This is presented as the goal of normalization, because it is not a proper technical definition. l You’ll find a more detailed treatment of the topic in The Book at p 318. And now the last of the KRB Seven Steps. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 121

9. 2. The KRB Seven-Step Method. Step Candidate Classes Step Define Classes Step Establish 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 Copyright Operations (i. e. , Behavior) 8 2002 Flying Kiwi Productions Inc. [email protected] com 122

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Copyright 8 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 123

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) l The 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) l The final part of the analysis is to find the operations to go with the class diagram. l This is the part that is new with objects. l Chapters 10 and 11 each present a method that will help to find behaviors. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 124

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) l At 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) l At this stage, we just need some of the behaviors. names for l We just need to know what behaviors exist. l Later, in the Design phase, we’ll look at each one in detail, l And spec them out for the programmers to code. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 125

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) l The 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) l The idea is to apply several techniques, l And each one will find a bunch more behaviors for you. l The next few slides will briefly discuss a selection of six techniques. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 126

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques for Finding Operations 1. By Inspection 2. Basic CRUD 3. Use Cases 4. Statechart Diagram 5. CRC Cards 6. CRUD Revisited Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 127

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 1. By 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 1. By Inspection: l With the users, ask the question: l “What can a. . . DO? l For example, n What can a Student do? Create herself (i. e. , her record, or instance, in the database. s Enrol himself in a class. s Pay her fees. s Gain a grade in a course. s Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 128

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 1. By 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 1. By Inspection: n What can a Customer do? s s s n What can a Product do? s s s Copyright Create her/himself Buy a Product Pay a bill Return a Product Change address Create Get stock in Sell some Update Unit Price Change tax status 8 2002 Flying Kiwi Productions Inc. [email protected] com 129

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques for Finding Operations 1. By Inspection 2. Basic CRUD 3. Use Cases 4. Statechart Diagram 5. CRC Cards 6. CRUD Revisited Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 130

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 2. Basic 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 2. Basic CRUD: Every class has to have some way for its instances to be: Created Read Updated, and Deleted Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 131

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 2. Basic 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 2. Basic CRUD: l Among all the behaviors, there must be at least one behavior to look after each of these four functions. l Don’t bother writing in the four functions, but do check at the end (after the techniques from Chapters 10 and 11) to make sure all four (C, looked after, Copyright R, U, D) have been For each class. 8 2002 Flying Kiwi Productions Inc. [email protected] com 132

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 2. Basic 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 2. Basic CRUD: We’ll do some more CRUD in a moment, But first, Use Cases and a commercial for the next two chapters. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 133

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques for Finding Operations 1. By Inspection 2. Basic CRUD 3. Use Cases 4. Statechart Diagram 5. CRC Cards 6. CRUD Revisited Copyright 8 2002 Flying Kiwi Productions Inc. [email protected]me. com 134

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 3. Use 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 3. Use Cases: l Scan your Use Cases, and at each step, l Consider what behaviors the objects would need to perform to output or input the data you need for the Use Case. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 135

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques for Finding Operations 1. By Inspection 2. Basic CRUD 3. Use Cases 4. Statechart Diagram 5. CRC Cards 6. CRUD Revisited Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 136

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 4. Statechart 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 4. Statechart Diagram: l The Statechart Diagram can be a fruitful source of behaviors. l It is favored by several of the Gurus, l Among them Shlaer and Mellor, l And James Rumbaugh et al. l We will study the Statechart Diagram in detail in Chapter 10. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 137

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques for Finding Operations 1. By Inspection 2. Basic CRUD 3. Use Cases 4. Statechart Diagram 5. CRC Cards 6. CRUD Revisited Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 138

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 5. CRC 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 5. CRC Cards: l Rebecca Wirfs-Brock et al introduced the l Class-Responsibility-Collaboration Cards (CRC Cards) l As a sort of cardboard CASE tool. l They work well to trace the interactions among the various classes, l As they “collaborate” to get a task done. l We will use CRC cards extensively in Chapter 10, and also in Chapter 13. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 139

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Six techniques for Finding Operations 1. By Inspection 2. Basic CRUD 3. Use Cases 4. Statechart Diagram 5. CRC Cards 6. CRUD Revisited Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 140

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD Revisited: l When you think you have exhausted all the possibilities for finding behaviors, l Then for each class you need to do a CRUD Matrix. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 141

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD Revisited: List your classes down the left Customer Product Sale . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 142

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD Revisited: l List your classes down the left. l List business functions across the top l Or if you need to, across the top you can list any of these: Organization units n Positions (i. e. , jobs) n People n Use Cases n l Then you mark in each column what these people can do to this class. . . Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 143

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Product Sale 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Product Sale . . Copyright CRU M an ag em In ve ent nt or y s le Sa rs ye Bu ke ar M Customer . . tin g 6. CRUD Revisited: Marketing can Create, Read & Update instances of Customer. 8 2002 Flying Kiwi Productions Inc. [email protected] com 144

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD Revisited: Let’s say that in this company, l The Marketing department can Create, Read and Update Customer data, l But only Management can Delete Customers. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 145

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Customer CRU 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Customer CRU Product Sale . . Copyright 8 2002 Flying Kiwi Productions Inc. . M ar ke tin g Bu ye rs Sa le s M an ag em In ve ent nt or y 6. CRUD Revisited: D But only Management can Delete Customers. [email protected] com 146

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD Revisited: Then the rest of the matrix might go like this Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 147

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Customer CRU 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) Customer CRU Product RU Sale R . . Copyright RU CRU R 8 2002 Flying Kiwi Productions Inc. . M ar ke tin g Bu ye rs Sa le s M an ag em In ve ent nt or y 6. CRUD Revisited: D Then the rest of the matrix might go like this RU CRUD CRU RD [email protected] com 148

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) 6. CRUD Revisited: l So you must check each of your classes, to ensure that you have not missed one of the four basic functions: Copyright 8 2002 Flying Kiwi Productions Inc. C, R, U& D [email protected] com 149

9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) l Which 9. 2. The KRB Seven-Step Method. Step Operations (i. e. , Behavior) l Which brings us to the end of the KRB Seven Steps, l We now have three sections left to consider: n Is it a class or is it an attribute? n Finding Structures n Adapting the Method Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 150

Chapter 9: Finding Objects and Classes in the Real World 9. 1. The Importance 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. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 151

Chapter 9: Finding Objects and Classes in the Real World 9. 3. Is It Chapter 9: Finding Objects and Classes in the Real World 9. 3. Is It A Class or Is It An Attribute? Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 152

9. 3. Is It A Class or Is It An Attribute? l This is 9. 3. Is It A Class or Is It An Attribute? l This is a frequent problem during Analysis. l When you apply the first two questions to a Candidate Class: What is a. . . ? (Definition) n How do I tell one. . . from another? (Identifier) n l Often these are still not enough to tell if this is a class, or just an attribute of some class. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 153

9. 3. Is It A Class or Is It An Attribute? l. The key 9. 3. Is It A Class or Is It An Attribute? l. The key to deciding is the third question: Sample Attributes or Behaviors. l If there attributes to describe it, l And/or behaviors it can do (or have done to it) Then there must be a class to attach them to! Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 154

9. 3. Is It A Class or Is It An Attribute? l The downside 9. 3. Is It A Class or Is It An Attribute? l The downside is that the more classes your project has, l The more work there is coding and implementing them, l And maybe longer response times too. l Often in the Design phase we decide to break the rules and de-normalize, l Like maybe putting the Customer Name attribute in the Sale class. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 155

9. 3. Is It A Class or Is It An Attribute? l But remember 9. 3. Is It A Class or Is It An Attribute? l But remember this is a Design decision, and must be deferred to the Design phase. l At Analysis we should model the “pure” way, l And “corrupt” our pure design later. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 156

9. 3. Is It A Class or Is It An Attribute? So at Analysis 9. 3. Is It A Class or Is It An Attribute? So at Analysis time the rule of thumb is: If in doubt Model it as a class. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 157

Chapter 9: Finding Objects and Classes in the Real World 9. 1. The Importance 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. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 158

Chapter 9: Finding Objects and Classes in the Real World 9. 4. Finding Structures. Chapter 9: Finding Objects and Classes in the Real World 9. 4. Finding Structures. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 159

9. 4. Finding Structures. Subclass Hierarchies Aggregations Components and Wholes s Container-Contents s Collection-Member 9. 4. Finding Structures. Subclass Hierarchies Aggregations Components and Wholes s Container-Contents s Collection-Member s Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 160

9. 4. Finding Structures. Subclass Hierarchies l Specializations: n Look for kindsa in all 9. 4. Finding Structures. Subclass Hierarchies l Specializations: n Look for kindsa in all your classes n Are there attributes or operations that are only needed by certain instances and not by the entire class? n Do some relationships affect only a subset within the class? n Could this class be viewed as a subclass of something in your class libraries? Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 161

9. 4. Finding Structures. l Generalizations: n Does. there seem to be a cluster 9. 4. Finding Structures. l Generalizations: n Does. there seem to be a cluster of • Attributes, • Operations or • Associations that appear in several classes? n Consider semantics - (remember the cow and the barn, p 126) Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 162

9. 4. Finding Structures. Aggregations Components and Wholes s Container-Contents s Collection-Member s l 9. 4. Finding Structures. Aggregations Components and Wholes s Container-Contents s Collection-Member s l These are much more rare than subclasses, l But may sometimes make your models more readable or understandable. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 163

9. 4. Finding Structures. Aggregations s. Components and Wholes s. Container-Contents s. Collection-Member l 9. 4. Finding Structures. Aggregations s. Components and Wholes s. Container-Contents s. Collection-Member l Are there any attributes on this class that don’t really describe “one of these” but rather some object that is in some way “within” it? l Any operations that are performed by a “piece” of the object, not the object itself? l Associations that involve only a “piece” or “part” of the object? l Check other models in the same business area, possibly from other companies. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 164

Chapter 9: Finding Objects and Classes in the Real World 9. 1. 9. 2. Chapter 9: Finding Objects and Classes in the Real World 9. 1. 9. 2. 9. 3. 9. 4. The Importance of This Step. The KRB Seven-Step Method. Is It A Class or Is It An Attribute? Finding Structures. 9. 5. Adapting the Method. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 165

Chapter 9: Finding Objects and Classes in the Real World 9. 5. Adapting the Chapter 9: Finding Objects and Classes in the Real World 9. 5. Adapting the Method. Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 166

Chapter 9: Finding Objects and Classes in the Real World The KRB Method works Chapter 9: Finding Objects and Classes in the Real World The KRB Method works well in JAD/FTS sessions It can be easily adapted to other situations: One-on-one client interviews n Delphi Method n s Copyright Meet, combine, circulate 8 2002 Flying Kiwi Productions Inc. [email protected] com 167

Chapter 9: Finding Objects and Classes in the Real World The most critical factor Chapter 9: Finding Objects and Classes in the Real World The most critical factor is User Involvement Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 168

Chapter 9: Finding Objects and Classes in the Real World The users must: l Chapter 9: Finding Objects and Classes in the Real World The users must: l Make an adequate commitment of time l Have good warning of the time commitment that will be required of them l Be high-caliber workers who know their field or profession thoroughly l Be chosen from a variety of levels Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 169

End of Chapter 9 Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 170 End of Chapter 9 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 170

End of Chapter 9 Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 171 End of Chapter 9 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 171

End of Chapter 9 Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 172 End of Chapter 9 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 172

End of Chapter 9 Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 173 End of Chapter 9 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 173

Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 174 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 174

Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 175 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 175

Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 176 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 176

Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 177 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 177

Copyright 8 2002 Flying Kiwi Productions Inc. flykiwi@home. com 178 Copyright 8 2002 Flying Kiwi Productions Inc. [email protected] com 178