Domain Modeling http flic krp9 RR 1 BL
Domain Modeling http: //flic. kr/p/9 RR 1 BL
4 SWEBOK KAs covered so far 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. Software Requirements Today’s topic: Software Design Software Construction Software Testing Software Maintenance Software Configuration Management Software Engineering Process Software Engineering Models and Methods Software Quality Software Engineering Professional Practice Software Engineering Economics Computing Foundations Mathematical Foundations Engineering Foundations Analysis
Analysis bridges the gap between requirements and design http: //flic. kr/p/a 1 NZHb Design Analysis Requirements
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 – Esp. for MVC model classes
http: //flic. kr/p/4 Ut. Qzk Running Example: Point-of-Sale (POS) System
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) How to diagram classes?
POS Domain Model Box for each class Classes: concepts or entities in the problem domain (not software) Name of class Compartment (optional if empty) How to diagram classes?
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 How to diagram attributes?
POS Domain Model Classes: concepts or entities in the problem domain (not software) Attributes: number or text properties of conceptual classes Attribute names in compartment How to diagram attributes?
Is it a class or an attribute? If we think of an idea/thing as a number or text in the real world, it is probably an attribute, not a conceptual class
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 Name Reading direction 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?
How to find conceptual classes: Noun phrase identification • Identify nouns and noun phrases in descriptions of a domain • Nouns = candidate classes or attributes • Example (noun phrases bolded):
• 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 Tip: Think like a mapmaker
Recall 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?
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!!!
When to model subclasses? Would you model this?
Guideline: Model a subclass when… • subclass has additional attributes of interest AND/OR • subclass has additional associations of interest AND/OR • subclass is operated on, handled, reacted to, or manipulated differently in ways that are of interest AND/OR • subclass represents an animate thing (e. g. , animal) that behaves differently in ways that are of interest
Payment You can have cash, credit, and check payments, but can you ever really have just a Payment?
No. Payment is what we call an abstract class as opposed to a concrete class abstract Payment concrete
Abstract class indicated by italics
… or when drawing by hand use Payment {abstract} Payment
POS Example: Generalization Does this model obey: • The 100% Rule? • The Is-a Rule?
Think-Pair-Share Activity (Quiz): Creating a Domain Model 1. Think – Identify nouns and noun phrases—for inspiration – Sketch class diagram 2. Pair – Join your partner – Collaboratively draw a class diagram • Make tentative decisions quickly, then debate 3. Share – I’ll randomly select diagram(s) to discuss • Identify one thing that you wish you’d thought of • Identify one thing that you would do differently
http: //flic. kr/p/YSY 3 X What’s next?
- Slides: 31