Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jan 21, 200291. 3913 Ron McFadyen1 Ch 10. Domain Model: Visualizing Concepts Domain model illustrated with a class diagram (with no operations defined)

Similar presentations


Presentation on theme: "Jan 21, 200291. 3913 Ron McFadyen1 Ch 10. Domain Model: Visualizing Concepts Domain model illustrated with a class diagram (with no operations defined)"— Presentation transcript:

1 Jan 21, 200291. 3913 Ron McFadyen1 Ch 10. Domain Model: Visualizing Concepts Domain model illustrated with a class diagram (with no operations defined) emphasis on real-world objects a visual dictionary a map of concepts in a domain contains (conceptual) classes from the problem domain associations attributes

2 Jan 21, 200291. 3913 Ron McFadyen2 Ch 10. Domain Model: Visualizing Concepts Domain model Bottom of Page 138 “ … the most common mistake when creating a domain model is to represent something as an attribute when it should have been a concept. “ If we do not think of some conceptual class X as a number or text in the real world, X is probably a conceptual class, not an attribute.

3 Jan 21, 200291. 3913 Ron McFadyen3 Identifying conceptual classes Linguistic analysis identify the nouns present in Use Cases and other descriptions Using analysis patterns (advanced) Analysis Patterns, Fowler 1995 Data Model Patterns, Hay 1996 Read these books (next year or so)

4 Jan 21, 200291. 3913 Ron McFadyen4 Identifying Classes Books and journals The library contains books and journals. It may have several copies of a given book. Some of the books are for short term loans only. All other books may be borrowed by any library member for three weeks. Members of the library can normally borrow up to six items at a time, but members of staff may borrow up to 12 items at one time. Only members of staff may borrow journals. Borrowing The system must keep track of when books and journals are borrowed and returned, enforcing the rules described above Noun Identification

5 Jan 21, 200291. 3913 Ron McFadyen5 Identifying Classes - candidate list library book journal copy of a given book short term loan library member week Member of the library item time member of staff system rule discard - outside scope discard - not an object (yet, anyway) discard - redundant see “Members of the library” discard - not a thing (here) discard - too vague, turns out to be book or journal discard - outside scope discard - part of the meta-language, not part of the domain discard - part of the meta-language

6 Jan 21, 200291. 3913 Ron McFadyen6 Identifying Classes - result book journal copy of a given book Member of the library member of staff Domain Classes The domain is the application area we are working in These classes describe our problem space Natural classes from the problem space the user can appreciate

7 Jan 21, 200291. 3913 Ron McFadyen7 Identifying Objects - result book journal copy of a given book Member of the library member of staff Class Diagram We can place these in a diagram and illustrate how they are related by creating the appropriate associations

8 Jan 21, 200291. 3913 Ron McFadyen8 A Class Diagram Book CopyLibraryMember MemberOfStaff Journal 0..10..* 0..10..* 1..* 1 is a copy of borrows/returns

9 Jan 21, 200291. 3913 Ron McFadyen9 Ch 10. Domain Model: Visualizing Concepts Flight destination arrival vs Flight destination arrival Airport Destination and arrival airports as attributes Destination and arrival airports as assocations Preferred

10 Jan 21, 200291. 3913 Ron McFadyen10 Specification (Description) conceptual classes P. 142: Include a specification class when we need a description of something irrespective of its existence deletions result in loss of information it reduces duplicated information Sale SaleLineItemProductSpecification

11 Jan 21, 200291. 3913 Ron McFadyen11 Specification (Description) conceptual classes - Airline Example Flight is a class that keeps track of flight number, date and time for a flight, departure and arrival airports. departs from arrives in arrival departure * *1 1 Flight number date time name address Regardless of the date/time of a flight, the number and the airports involved stay constant. Airport

12 Jan 21, 200291. 3913 Ron McFadyen12 Specification (Description) conceptual classes - Airline Example Flight date time Larman suggests the use of a Description/Specification Conceptual Class to hold these attributes - to avoid an anomaly relating to information disappearing due to objects being deleted. FlightDescription number * 1 departs from arrives in arrival departure * *1 1 name address Airport

13 Jan 21, 200291. 3913 Ron McFadyen13 Page 164: Focus on those associations for which knowledge of the relationship needs to be preserved for some duration “need-to-know” associations Avoid showing redundant or derivable associations Associations correspond to verbs expressing a relationship between classes objects do not exist in isolation - they fit together in some way

14 Jan 21, 200291. 3913 Ron McFadyen14 “need-to-know” associations Flight date time Our database needs to record, to keep track of, when flights are scheduled, where they fly from and to - I.e. we need to know (or be able to derive) this information. FlightDescription number * 1 departs from arrives in arrival departure * *1 1 name address Airport

15 Jan 21, 200291. 3913 Ron McFadyen15 no redundant associations departs from arrives in arrival departure Flight date time name address We can always derive the departure and arrival airports for a flight, so we don’t need to have these 2 redundant relationships Airport FlightDescription number * 1 * * 1 1 arrival departure

16 Jan 21, 200291. 3913 Ron McFadyen16 * 0..1 Page 158: “ a person can be Married-to only one other person at any particular moment, even though... Person is Married to ? Multiplicity

17 Jan 21, 200291. 3913 Ron McFadyen17 * 0..1 Page 158: “ the car is only Stocked-by one dealer... Car Stocked-by ? Dealer Multiplicity

18 Jan 21, 200291. 3913 Ron McFadyen18 1 0..1 Page 159: “ … The answer depends on our interest in using the model... Store Stocks ? Item Multiplicity *

19 Jan 21, 200291. 3913 Ron McFadyen19 Page 160: ? 0..1 1 Person Supervises Multiplicity *

20 Jan 21, 200291. 3913 Ron McFadyen20 Pages 156, 162: “association checklist” typical ways in which associations arise A is physically contained in B … Section in a Book A is an organizational subunit of B … Faculty in a University etc Associations

21 Jan 21, 200291. 3913 Ron McFadyen21 P. 165 : Larman indicates that some of these may not be needed - not really part of the requirements - may not need-to- know all that are shown here Associations

22 Jan 21, 200291. 3913 Ron McFadyen22 attributes are preferably primitive (or just data types) boolean, date, number, string,... Invoice invDate: date Attributes

23 Jan 21, 200291. 3913 Ron McFadyen23 Non-primitive types where the associated things don’t need to be distinguished, such as phone number, quantities, points … the abstraction makes sense in the problem domain a phone number has many parts an item number that has subparts in its encoding price is a Currency amount is a Currency qty_ordererd is a Quantity these make sense in the problem domain price * qty_ordered makes sense Attributes

24 Jan 21, 200291. 3913 Ron McFadyen24 An Invoice will have a grand total Each Invoice Line will have a quantity ordered and a subtotal InvLine amount: Currency qty_ordered: Quantity Quantity amount: Number Invoice invDate: date amount: Currency Attributes Currency amount: Number

25 Jan 21, 200291. 3913 Ron McFadyen25 Page 172: No Foreign Keys as attributes in the Domain Model foreign keys are considered later in design example: an Invoice is not shown with an attribute for Customer; that is handled by the association between Customer and Invoice Invoice invDate: date Customer name: string address: string Attributes

26 Jan 21, 200291. 3913 Ron McFadyen26 Page 175: Derived attributes the UML notation is to prefix the attribute with a / SalesLineItem /quantity /subtotal Item 1..*0, 1 In this case, according to the model, there could be several items related to one line in the sale. These items are all the same type, and the quantity is therefore derivable by counting the number of related items. We are just adding more information to the model. Attributes

27 Jan 21, 200291. 3913 Ron McFadyen27 Video ID Stocks  Rents  Rents-from  1 1.. * 1 * 1 * VideoStore address name phoneNumber Customer address name phoneNumber Video store example

28 Jan 21, 200291. 3913 Ron McFadyen28 VideoRental dueDate returnDate returnTime CashPayment amount : Money Video ID Stocks  Rents  Rents-from  Pays-for  Initiates  1 1 1.. * 1 1 1 * 1 * 1 * RentalTransaction date1 ** VideoStore address name phoneNumber Customer address name phoneNumber 1 Records-rental-of  0..1 1 Video store example More detail added:

29 Jan 21, 200291. 3913 Ron McFadyen29 title subjectCategory Video ID  Specification (Description) conceptual classes Where do we keep track of the title or other descriptions for things like the videos that are rented? ?

30 Jan 21, 200291. 3913 Ron McFadyen30 Catalog VideoDescription title subjectCategory Video ID Stocks  Owns-a  Described-by  1 1 * 1 1 1 * * 1.. * VideoStore address name phoneNumber 1 Specification (Description) conceptual classes VideoDescription is a class that keeps track of the title and subject category for videos.


Download ppt "Jan 21, 200291. 3913 Ron McFadyen1 Ch 10. Domain Model: Visualizing Concepts Domain model illustrated with a class diagram (with no operations defined)"

Similar presentations


Ads by Google