Beruflich Dokumente
Kultur Dokumente
Domain Models
Why do this?
If you dont understand the domain, you cant program for it effectively Lower the representational gap between mental model and software model
Objectives
Identify conceptual classes related to the current iteration Create an initial domain model Model appropriate attributes and associations
Software Artifacts:
SalesDatabase
Conceptual Classes
An idea, thing, or object SymbolWords or images representing a conceptual class IntensionDefinition of a conceptual class ExtensionThe set of examples to which the class applies It is not a data model
10
11
Noun Phrases
Analyze each subject and object as follows:
Does it represent a person performing an action? Then its an actor, R. Is it also a verb (such as deposit)? Then it may be a method, M. Is it a simple value, such as color (string) or money (number)? Then it is probably an attribute, A. Which NPs are unmarked? Make it C for class. Verbs can also be classes, for example: Deposit is a class if it retains state information
CS6359 Fall 2012 John Cole 12
13
POS example
You can create a list, or you can use a set of class diagrams, per the table below
Register Item Store Sale
Sales LineItem
Cashier
Customer
Manager
Payment
Product Catalog
Product Specification
14
15
16
Report Objects
Including reports in a domain model usually isnt useful because the information is derived from other objects. There are special cases, such as receipts, that should be in the model.
17
19
Description Classes
A description class contains information that describes something else E. g. Product Description records the price, picture, text description (and what else?) of an item
20
21
Associations
Relationship between (instances of) classes that indicates some interesting and meaningful connection What objects need memory of a relationship? In Monopoly, where each piece is and which player owns which token No need to remember numbers on the dice
22
Associations (contd)
Avoid having too many; this adds communication paths and complexity Will they be implemented in software? UML: Line between classes with the name of the association Name with VerbPhrase-ClassName format. E. g. Sale Paid By CashPayment Each end of an association is called a Role
CS6359 Fall 2012 John Cole 23
Associations (contd)
Multiplicity: how many instances of class A can be associated with an instance of class B. E. g. an instance of Store can be associated with many (zero or more) Items This is at a particular moment, not over time Discussion of 0..1 or 1 Multiple associations: Flight FliesTo and FliesFrom an airport Common Associations List on p. 155
CS6359 Fall 2012 John Cole 24
Attributes
An Attribute is a logical data value of an object You can also have derived attributes denoted by / before the name Full syntax: visibility Name : type multiplicity = default {property string} +pi : Real=3.14159 {read-only}
Sale date startTime : Time
CS6359 Fall 2012 John Cole 25
attributes
Attribute Types
Usually primitive data types, as well as things like Color, DateTime, Zip code, etc. The latter are specializations of primitive types It should not normally be a class, such as Sale or Airport Relate conceptual classes with an association, not an attribute. No foreign keys Attributes in code are okay
CS6359 Fall 2012 John Cole 26
28
Payment
Has-amount
Is-in
Unit 1 ...
*
Payment amount : Quantity
better
29
30