Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 9 Domain Models. Domain Modeling After you have your requirements you start modeling the domain. You are still modeling the business, not the.

Similar presentations


Presentation on theme: "Chapter 9 Domain Models. Domain Modeling After you have your requirements you start modeling the domain. You are still modeling the business, not the."— Presentation transcript:

1 Chapter 9 Domain Models

2 Domain Modeling After you have your requirements you start modeling the domain. You are still modeling the business, not the program classes Various influences: –Source of info is the use-cases –operational contracts (like pre- and post-conditions) –conceptual classes give us ideas for what to name our program classes

3 Fig. 9.1

4 Example: The following are the conceptual classes for Payment and Sale. Part of the Conceptual Perspective Don’t be too thorough; avoid waterfall.

5 Fig. 9.2 NOTE: The direction of references.

6 What is a Domain Model Decompose the domain into noteworthy concepts and/or objects. The DM is a visual representation of real-situation objects and conceptual classes. Sometimes called Conceptual Model. In UP, this is one of the Business Modeling artifacts. Specifically, a class diagram with no operations or behaviour. Shows: –domain objects –associations –attributes

7 And… Sometimes called a visual dictionary.

8 What not to include: Software artifacts like databases, windows Responsibilities (ie, methods)

9 Fig. 9.3

10 Where does it fit? The Domain Model feeds into just one part of a program’s design. Typical program uses the MVC (Model-View-Controller) paradigm; the DM feeds the Model part only. The author uses the term “domain layer” to mean the software components that underlie the UI layer. We consider a conceptual class from 3 points of view –symbol: what words we use to name it –intension: its complete definition –extension: a set of examples of the class

11 Are Domain and Data Models the same? A Data Model is a model of persistent data; ie, data in a database or file system. Unlike a Data Model, just because we may never build the class, doesn’t mean we don’t put it in a Domain Model. Some Domain Model classes are purely behavioural

12 Fig. 9.5

13 Why Build a Domain Model? The developer has to understand the business so that is a good reason to build the Domain Model We want to use software artifact names that “remind” us of what real-world things they model. So it is a good idea to list those domain concepts (visually). The author calls this a “low representational gap”.

14 Fig. 9.6

15 Guidelines: Limit yourself to the interests of the current iteration; don’t try to draw the entire Domain Model up front (waterfall). To decide what classes to use, look around at what other developers have done here or in this area of endeavour. Look for patterns others have built. Our project uses Quartz. Make lists. Linguistic Analysis

16 List of Categories and possible classes Business TransactionsSale, Payment, Reservation Transaction Line ItemsSalesLineItem Products or ServicesItem, Flight, Seat, Meal Where Transaction RecordedRegister, Ledger, Manifest People’s RolesCashier, Customer, Passenger Place of TransactionStore, Airport, Plane, Seat Noteworthy EventsSale, Payment, Flight Physical ObjectsItem, Register, Board, Airplane Descriptions of ThingsProductDescription, FlightDescription Conceptual Class Category Examples

17 List of Categories and possible classes CatalogsProductCatalog, FlightCatalog Containers for ThingsStore, Bin, Airplane Things in ContainersItem, Square (on a Board), Passenger Other SystemsCreditAuthSystem, AirTrafficControl Records of Finance, WorkReceipt, Ledger, MaintenanceLog Financial InstrumentsCash, Check, LineOfCredit,TicketCredit Schedules, Manuals, DocsDailyPriceChangeList, RepairSchedule Conceptual Class Category Examples

18 Linguistic Analysis: Identify the nouns and verbs in text descriptions like a text-based Use-Case; consider these as candidate conceptual classes.

19 Fully Dressed Use Case (1): Scope: NextGenPOSApplication Level: User Goal PrimaryActor: Cashier StakeholdersAndInterests: –cashier wants: … –customer wants: … –company wants: … –manager wants: … –government wants: … –CC company wants: …

20 Fully Dressed Use Case (2): Preconditions: Cashier identified and authenticated Postcondtions: Sale completed, tax calculated, inventory updated, commission recorded, cc approval recorded MainSuccessScenario: 1.Customer arrives with goods 2.Cashier starts new sale 3.Cashier enters item identifier 4.Systems records sale and presents description and running total (repeat 3-4 many times) 1.System presents total 2.…

21 POS Example: Take from our various analyses, the relevant class names. Don’t include things that aren’t part of this iteration, for example CreditCardAuthorization.

22 Fig. 9.7

23 Fig. 9.8 NOTE: We keep the box not fully formed; easy to add stuff.

24 What about Using a Tool? There is little motivation to update a model unless it is easy to do so. That is why the author likes the whiteboard. The practical reason for updating is to keep the model as a documentation tool (for version 2).

25 Missing Classes (Receipt): This is a report on functionality of other classes so is a repetition of previously modeled info. Reason to exclude. Confers rights to return to Customer: Reason to Model Not doing returns now: Leave it out. Rules of Thumb: –Use existing names –exclude features that are not part of the iteration or plan –don’t add stuff that is not there

26 Weird Domains like Telecommunications: Some classes might be: Message, Connection, Port, dialog, Route, Protocol.

27 Attributes vs Classes: A common mistake is to cross identify these things. Rule of Thumb 1: If you don’t think of something as a number or string in the real world, it probably is a class. Rule of Thumb 2: Classes are capable of independent existence; attributes are properties of things. Rule of Thumb 3: If all you know about something is it exists and nothing else; it may be an attribute.

28 Examples: Sale store SaleStore phone or? Flight destination FlightAirport name or?

29 When to Model Descriptions? A description class describes something else. The difference between an object and a description of it is like the difference between a copy of a book and a book itself. If you run out of copies you may still need to know about the book. Intension vs Extension Physical Object vs Type of Thing So we need an Item class and a ProductDescription. How do you tell them apart? Identify their keys or identifying attributes. –serial number vs model number

30 Fig. 9.9 Book Copy

31 Fig. 9.10 What is the key?

32 Associations: A relationship between classes (or instances of classes). When do we show them? –when we need (real-world) to remember the other Too many associations make for an unwieldy diagram What associations are “implemented”? –Not all –some new ones appear between software objects Representations:

33 Fig. 9.11

34 Fig. 9.12 How many instances of Sale can be associated with an instance of Register? Ans: 0 or 1 NOTE: Not over time!!

35 Fig. 9.13 Many instances of item with the same store

36 Fig. 9.14

37 Fig. 9.15 0 instances of Store related to some instance of Item NOTE: For those in my database class: these are not participation numbers.

38 Multiple Associations:

39 Fig. 9.16 Employeemanages

40 Where to Start Adding Associations: A is a transaction related to another transaction B Payment - Sale A is a line item of a transaction BSalesLineItem - Sale A is a product or service for a transaction (or line item) B Item - SalesLineItem A is a role related to a transaction BCustomer - Payment A is a physical or logical part of BDrawer - Register A is physically or logically contained in BRegister - Store A is a description of BProductDescription - Item A is known/logged/captured in BSale - Register A is a member of BCashier - Department A is an organizational subunit of BDepartment - Store A uses or manages or owns BCashier - Register A is next to BSalesLineItem - SalesLineItem

41 Fig. 9.17

42 Fig. 9.18

43 Attributes: A property of a class or association. Find them in the text analysis of the requirements

44 Fig. 9.19 derived

45 Fig. 9.20 NOTE: You can “invent” obvious data types on your own

46 Fig. 9.21 I disagree An Item may never be sold

47 Fig. 9.22 Register is a complex thing

48 Fig. 9.23

49 Guidelines for Representing Data Types: composed of separate sections line an address operations associated with it – social security number has other attributes like validity date range a quantity with a unit type type abstraction: URL

50 Fig. 9.24 Might need Addresses for a delivery schedule Never gets shown as a class because it has not complexity other than the fact that it is a code.

51 Fig. 9.25 Don’t use attributes to represent associations in the Domain Model (ie foreign key syndrome)

52 Fig. 9.26 Quantities and Units

53 Fig. 9.27

54 Fig. 9.28


Download ppt "Chapter 9 Domain Models. Domain Modeling After you have your requirements you start modeling the domain. You are still modeling the business, not the."

Similar presentations


Ads by Google