GV Phi Loan - Khoa CNTT HUI
Content
Introduction of domain model Conceptual classes Associations Attributes
GV Phi Loan - Khoa CNTT HUI
Domain Model
Domain model is widely used as a source of inspiration for designing software objects.
A domain model is a visual representation of conceptual classes or real-world objects in a domain of interest.
GV Phi Loan - Khoa CNTT HUI
Domain Model
Domain model is illustrated with a set of class diagrams in which no operations are defined. It may show:
domain objects or conceptual classes associations between conceptual classes attributes of conceptual classes
GV Phi Loan - Khoa CNTT HUI
Domain Modeling Guidelines
1. 2. 3. List the candidate conceptual classes. Draw them in a domain model. Add the associations necessary to record relationships for which there is a need to preserve some memory Add the attributes necessary to fulfill the information requirements
4.
GV Phi Loan - Khoa CNTT HUI
Identifying Conceptual Classes
Method 1: Use a conceptual class category list. Method 2: Identify noun phrases from the use case specification.
GV Phi Loan - Khoa CNTT HUI
Method 1: Use a conceptual class category list
Making a list of candidate conceptual classes from a table contains many common categories.
GV Phi Loan - Khoa CNTT HUI
Use a conceptual class category list
GV Phi Loan - Khoa CNTT HUI
Use a conceptual class category list
GV Phi Loan - Khoa CNTT HUI
Identify noun phrases
Some of the noun phrases are candidate conceptual classes Some may be attributes of conceptual classes.
GV Phi Loan - Khoa CNTT HUI
10
Noun-extraction method
Main Success Scenario (or Basic Flow):
1. Customer arrives at a POS checkout with goods and/or services to purchase. 2. Cashier starts a new sale. 3. Cashier enters item identifier. 4. System records sale line item and presents item description, price, and running total. Price calculated from a set of price rules. Cashier repeats steps 2-3 until indicates done. 5. System presents total with taxes calculated. 6. Cashier tells Customer the total, and asks for payment.
GV Phi Loan - Khoa CNTT HUI
11
Noun-extraction method
7. Customer pays and System handles payment. 8. System logs the completed sale and sends sale and payment information to the external Accounting and Inventory systems 9. System presents receipt. [Link] leaves with receipt and goods Extensions (or Alternative Flows): 7a. Paying by cash: 1. Cashier enters the cash amount tendered
GV Phi Loan - Khoa CNTT HUI
12
Candidate Conceptual Classes for the Sales Domain
GV Phi Loan - Khoa CNTT HUI
13
Initial Domain Model
GV Phi Loan - Khoa CNTT HUI
14
Specification conceptual classes
Need for specification conceptual classes is common in many domain models. In a domain model, it is common to state that an Xspecification Describes an X
GV Phi Loan - Khoa CNTT HUI
15
Specification conceptual classes
Ex:ProductSpecification does not represent an Item, it represents a description of information about items.
Even if all inventoried items are sold and their corresponding Item software instances are deleted, the ProductSpecifications still remain.
GV Phi Loan - Khoa CNTT HUI
16
Specification conceptual classes
GV Phi Loan - Khoa CNTT HUI
17
Associations
An association is a relationship between conceptual class types that indicates some meaningful and interesting connection
UML: associations are defined as "the semantic relationship between two or more classifiers that involve connections among their instances
GV Phi Loan - Khoa CNTT HUI
18
Associations
GV Phi Loan - Khoa CNTT HUI
19
UML Association Notation
As a line between classes with an association name.
A is a physical or logical part of B. A is physically or logically contained in/on B. A is recorded in B.
Avoid showing redundant or derivable associations.
GV Phi Loan - Khoa CNTT HUI
20
Case study 1: POS
GV Phi Loan - Khoa CNTT HUI
21
Case study 1: POS
GV Phi Loan - Khoa CNTT HUI
22
Roles
Each end of an association is called a role. Roles may optionally have:
Name multiplicity expression Navigability (arrow)
GV Phi Loan - Khoa CNTT HUI
23
Multiplicity
Defines how many instances of a class A can be associated with one instance of a class B
GV Phi Loan - Khoa CNTT HUI
24
Multiplicity values
GV Phi Loan - Khoa CNTT HUI
25
Multiplicity
The multiplicity value communicates how many instances can be validly associated with another, at a particular moment, rather than over a span of time. Ex: with monogamy laws, a person can be Married-to only one other person at any particular moment, even though over a span of time, they may be married to many persons.
GV Phi Loan - Khoa CNTT HUI
26
Naming Associations
Based on a TypeName-VerbPhraseTypeName format Should start with a capital letter.
GV Phi Loan - Khoa CNTT HUI
27
Associations and Implementation
During domain modeling, an association is not a statement about data flows,instance variables, or object connections in a software solution; it is a statement that a relationship is meaningful in a purely conceptual sense their presence in a conceptual view of a domain model does not require their implementation.
GV Phi Loan - Khoa CNTT HUI
28
A partial domain model.
GV Phi Loan - Khoa CNTT HUI
29
Domain Model: Adding Attributes
An attribute is a logical data value of an object. Ex: the Sale conceptual class needs a date and time attribute.
GV Phi Loan - Khoa CNTT HUI
30
Valid Attribute Types
There are some things that should not be represented as attributes, but rather as associations. The attributes in a domain model should preferably be simple attributes or data types.
Very common attribute data types : Boolean, Date, Number, String (Text), Time Other common types : Address, Color, Geometries (Point, Rectangle),Phone Number, Social Security Number, enumerated types
GV Phi Loan - Khoa CNTT HUI
31
Example: Relate with associations, not attributes.
GV Phi Loan - Khoa CNTT HUI
32
No Attributes as Foreign Keys
Attributes should not be used to relate conceptual classes in the domain model.
Relate types with an association, not with an attribute.
GV Phi Loan - Khoa CNTT HUI
33
Example: Do not use attributes as foreign keys
CurrentRegisterNumber attribute in the Cashier class is undesirable because its purpose is to relate the Cashier to a Register object.
GV Phi Loan - Khoa CNTT HUI
34
Partial domain model
GV Phi Loan - Khoa CNTT HUI
35