domain modeling chandan r. rupakheti and steve chenoweth week 5, day 1
TRANSCRIPT
![Page 1: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/1.jpg)
Domain ModelingChandan R. Rupakheti and Steve ChenowethWeek 5, Day 1
![Page 2: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/2.jpg)
Today• Domain Modeling
• Notations
• Guidelines
• Practice
2
![Page 3: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/3.jpg)
Domain Model• The domain model is a representation of real-situation
conceptual classes
• The term does not mean a set of diagram describing software classes
• Bridges the representational gap between Use-Case Model and Software Design Model (such as Class and Interaction Diagrams)
3
Q1
![Page 4: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/4.jpg)
An Example – POS System
4
![Page 5: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/5.jpg)
Notation – UML Class Diagram• UML class diagram is used to model a domain with a twist
• Domain Class• Domain class consist of class name and attributes• Domain class does not have methods
• Relation• A line with a label represents the relation between two classes• A relation has a cardinality constraint
5
Q2
![Page 6: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/6.jpg)
How to Create Domain Model• Find conceptual classes
• Draw them as classes in a UML class diagram
• Add associations and attributes
6
![Page 7: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/7.jpg)
Finding Conceptual Classes• Reuse or modify the existing model if one exists
• Use a category list
• Identify noun phrases in your use-cases
7
![Page 8: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/8.jpg)
Category List (Partial)• Business transaction
• Sale, Payment, Reservation
• Product or service related to transaction• Item, Flight, Seat
• Where is the transaction recorded• Register, Ledger, FlightManifest
• Place of service• Store, Airport, Plane, Seat
8
![Page 9: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/9.jpg)
Identify Noun Phrase in Use Cases
Basic Flow for a POS System1. Customer arrives at a POS checkout with goods and/or
services to purchase2. Cashier start a new sale3. Cashier enters item identifier4. System records sale line item and presents item description,
price, and running total5. …
9
![Page 10: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/10.jpg)
List and Draw UML Diagram• Sale
• Cash Payment
• SaleLineItem
• Item
• Register
• Amount
• Cashier
• …
1. Decide which ones are classes and which ones are attributes2. Add attributes and relation to the identified domain classes
10
![Page 11: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/11.jpg)
Part of POS System
11
![Page 12: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/12.jpg)
Attributes vs. Classes
- or -
- or -
- or -
12
Q3
![Page 13: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/13.jpg)
Description Classes• A description class contains information that describes
something else
• E.g. Item and ProductDescription
13
![Page 14: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/14.jpg)
When to use Description Class
• When information must be retained independent of existence of instances of the described item
• When deleting the described item could result in information loss
• When it reduces redundant information
14
Q4
![Page 15: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/15.jpg)
Avoid Premature Design
Good
Avoid
Avoid
15
![Page 16: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/16.jpg)
Confusion with Databases
• Domain model ≠ Data model
• Data models:• Only show persistent data• Exclude classes that don’t have attributes
• Domain models may include:• External actors, transient data, any real-world classes• Also classes without attributes/data that have a purely behavioral
role
16
Q5
![Page 17: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/17.jpg)
Don’t Have Too Much Details
17
![Page 18: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/18.jpg)
Association NotationsAssociation name: Use verb phrase Capitalize Typically camel-case or
hyphenated Avoid “has”, “use”
Multiplicity (Cardinality): ‘*’ means “many” x..y means from x to y
inclusively
Reading direction:Can exclude if association reads left-to-right or top-to-bottom
18
![Page 19: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/19.jpg)
Cardinality (or Multiplicity)zero or more; "many"
one or more
one to 40
exactly 5
T
T
T
T
*
1..*
1..40
5
T3, 5, 8
exactly 3, 5, or 8
19
![Page 20: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/20.jpg)
More Association• Classes can have multiple associations
• Classes can also self-associate! • Object creates itself• Object modifies itself• Object moves itself…
Flight Airport
Flies-to
Flies-from
*
* 1
1 20
![Page 21: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/21.jpg)
Attributes• An object’s logical data value that must be remembered
• Some attributes are derived from other attributes
• Usual primitive attributes (data types not shown in DM)
• Common compound attributes• Date, time, address, SSN, phone number, bar codes, etc.• May even become full class objects in design…
Sale
dateTime/ total : Money
attributes
derived attribute
21
![Page 22: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/22.jpg)
Visibility in Domain Models
Sale
- dateTime : Date- / total : Money
Private visibility attributes
Math
+ pi : Real = 3.14 {readOnly}
Public visibility readonly attribute with initialization
Person
firstNamemiddleName : [0..1]lastName
Optional value
22
![Page 23: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/23.jpg)
POS Domain Model
Register
ItemStore
Sale
CashPayment
SalesLineItem
CashierCustomer
ProductCatalog
ProductDescription
Stocks
*
Houses
1..*
Used-by
*
Contains
1..*
Describes
*
Captured-on
Contained-in
1..*
Records-sale-of
0..1
Paid-by Is-for
Logs-completed
*
Works-on
1
1
1
1 1..*
1
1
1
1
1
1
1
0..1 1
1
Ledger
Records-accounts-
for
1
1
23
![Page 24: Domain Modeling Chandan R. Rupakheti and Steve Chenoweth Week 5, Day 1](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649da25503460f94a8ef2c/html5/thumbnails/24.jpg)
Next …• In-class Exercise
• Create domain model for your project based on use cases (2 rich ones) that you have developed for Milestone 2
• Present your model to the class
24