799673a972c6544dfa2c29510c65d266.ppt
- Количество слайдов: 35
Domain Models http: //flic. kr/p/9 a 9 Rj. D
What are you going to learn about today? • Domain modeling: – why? – what? – how? • Diagramming domain models http: //flic. kr/p/8 Jpk. Tg
Recall: Iterative development process We are here http: //en. wikipedia. org/wiki/File: Iterative_development_model_V 2. jpg
Analysis bridges the gap between requirements and design http: //flic. kr/p/a 1 NZHb Design Analysis Requirements
What should we build? Requirements But we still don’t fully understand the problem domain! Analysis OK, now how should we build this thing? Design
Domain Model • “Most important—and classic—model in OO analysis” –Larman, p 131 • Captures entities, attributes, and relationships in the problem domain • Represented with UML class diagram – Conceptual classes • As opposed to software or implementation classes • Acts as inspiration for some software classes – Lowers representational gap
Larman Case Study: Next. Gen POS System • POS = Point of Sale • Computerized application used (in part) to record sales and handle payments • Typically used in retail store • Includes hardware – E. g. : barcode scanner • Interfaces with various service applications – E. g. : tax calculator • Must be fault tolerant – E. g. : handle cash as backup http: //flic. kr/p/4 Ut. Qzk
POS Domain Model Classes: concepts or entities in the problem domain (not software)
POS Domain Model Classes: concepts or entities in the problem domain (not software) Attributes: number or text properties of conceptual classes
Is it a class or an attribute? If we do not think of an idea/thing as a number or text in the real world, it is probably a conceptual class, not an attribute
POS Domain Model Classes: concepts or entities in the problem domain (not software) Attributes: number or text properties of conceptual classes
POS Domain Model Classes: concepts or entities in the problem domain (not software) Attributes: number or text properties of conceptual classes Associations: relationships between classes
Associations
Associations Name
Associations Reading direction
Associations Multiplicities: Read as • each Register records 0 or more Sales • each Sale is recorded by exactly 1 Register
Examples of multiplicities Also common to see 0. . * 8
POS Domain Model How many Stores can an Item be stocked in? How many Items can a Store stock? How many Registers does a Store house? How many Sales Line. Items per Sale? How many Sales Line. Items can a particular Item be recorded in?
Consider the Payment class Payment There are different types of payments, like cash, credit, and check payments, and each type has some unique attributes How would you model the different payment types? http: //flic. kr/p/9 ksx. Qa
Answer: Use generalization superclass – more general concept Payment subclasses – more specialized concepts generalization relationship (3 overlapping triangle-arrows)
Generalization guideline: The 100% Rule 100% of the superclass’s definition should be applicable to the subclass • The subclass must conform to 100% of the superclass’s – attributes – associations Payment
Generalization guideline: The Is-a Rule All members of the subclass set must be members of the superclass set Informal test: “A Subclass is a superclass” – E. g. : “A Cash. Payment is a Payment” Remember this!!!
Did you notice something odd about this model? Payment You can have cash, credit, and check payments, but can you ever really have just a Payment?
abstract Payment concrete
Abstract class indicated by italics
Abstract class Or indicated with this property Payment {abstract}
POS Example: Generalization Does this model obey: • The 100% Rule? • The Is-a Rule?
FYI: Lots more to the UML class diagram notation Association classes Composition Qualified associations … and more!
Think-Group-Share Activity: Creating a Domain Model Before we start, here’s a few tips http: //flic. kr/p/5 dfuq. L
How to find conceptual classes: Noun phrase identification • Identify nouns and noun phrases in descriptions of a domain • Nouns = candidate classes or attributes • Use Case Example:
• Use existing names in the territory • Exclude irrelevant or out-of-scope features • Do not add things that are not there http: //flic. kr/p/5 QKv. Wh Think like a mapmaker
Tip: Sketch classes starting from the upper left Sale Payment Store address
Think-Group-Share Activity: Creating a Domain Model 1. Think – Identify nouns and noun phrases—for inspiration – Sketch class diagram 2. Group – Join your team at the whiteboard – Collaboratively draw a class diagram • Make tentative decisions quickly, then debate 3. Share – Look at each of the other teams’ diagrams • For each, identify one thing that you wish you’d thought of • For each, identify one thing that you would do differently http: //flic. kr/p/5 dfuq. L
A word about agile modeling (quoting Larman) Experienced analysts and modelers know the secret of modeling: The purpose of modeling (sketching UML, …) is primarily to understand, not to document. Thus, we favor hand-drawn diagrams over typeset ones http: //flic. kr/p/7 SFKjj
Summary • Domain models • Conceptual class diagrams – – – Attributes Associations Multiplicities Generalization Abstract classes • Noun phrase identification • Think like a mapmaker http: //flic. kr/p/YSY 3 X