300 likes | 316 Views
Learn how to create more expressive domain models and understand UML class diagram notation. Explore concepts like attributes, associations, and generalization.
E N D
Domain Models Part 2 http://flic.kr/p/9a9RjD
What are you goingto learn about today? • Making more expressive domain models • More on UML class diagram notation http://flic.kr/p/8JpkTg
Recall: Iterative development process We are here http://en.wikipedia.org/wiki/File:Iterative_development_model_V2.jpg
Recall: The purpose of analysis But we still don’t fully understand the problem domain! Analysis
Recall: Domain Models Classes: concepts or entities in the problem domain (not software)
Recall: Domain Models Classes: concepts or entities in the problem domain (not software) Attributes: number or text properties of conceptual classes
Recall: Domain Models Classes: concepts or entities in the problem domain (not software) Attributes: number or text properties of conceptual classes Associations: relationships between classes
Recall: Domain Models Classes: concepts or entities in the problem domain (not software) Attributes: number or text properties of conceptual classes Associations: relationships between classes
Recall: Noun-phrase identification technique • Identify nouns and noun phrases in descriptions of a domain • Nouns = candidate classes or attributes
Recall: Think like a mapmaker • 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/5QKvWh
Recall: Draw classes starting from the upper left Sale Payment Store address
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 modelthe different payment types? http://flic.kr/p/9ksxQa
Answer: Use generalization superclass – moregeneral concept Payment generalizationrelationship(3 overlappingtriangle-arrows) subclasses – morespecialized concepts
Generalization guideline: The 100% Rule Payment 100% of the superclass’s definition should be applicable to the subclass • The subclass must conform to 100% of the superclass’s • attributes • associations
Generalization guideline: The Is-a Rule All members of the subclass set must be members of the superclass set Informal test: “A Subclassis asuperclass” • E.g.: “A CashPayment is a Payment” Remember this!!!
When to model subclasses? Would you model this? http://flic.kr/p/9ksxQa
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
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
POS Example: Generalization • Does this model obey: • The 100% Rule? • The Is-a Rule?
Recall the Sales and Sales LineItem • A LineItem is a part of a Sale • They have a composition relationship • We can model this!
Recall the Sales and Sales LineItem Black diamond denotescomposition Read as: A sale is composedof 1 or more line items Note: Multiplicity on diamondend must be 1 or 0..1
Composition relationship implies … • An instance of the part belongs to only 1 composite instance AND • The part must always belong to a composite AND • The composite is responsible for creation/deletion of its parts
POS Example: Composition Does this model usecomposition correctly?(Only 1? Always belong? Creation/deletion?)
FYI: Lots more to the UML class diagram notation Association classes Qualified associations … and more!
Summary Domain modeling topics: • How to model classes • and their attributes • How to model relationships among classes • Association • Generalization • Composition • How to distinguish abstract from concrete classes http://flic.kr/p/YSY3X
Think-Group-Share Activity:Creating a Domain Model • Think • Identify nouns and noun phrases—for inspiration • Sketch class diagram • Group • Join your team at the whiteboard • Collaboratively draw a class diagram • Make tentative decisions quickly, then debate • 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/5dfuqL