Presentation is loading. Please wait.

Presentation is loading. Please wait.

Domain Model—Part 3: Associations, Multiplicity and Attribute- Text Notation.

Similar presentations


Presentation on theme: "Domain Model—Part 3: Associations, Multiplicity and Attribute- Text Notation."— Presentation transcript:

1 Domain Model—Part 3: Associations, Multiplicity and Attribute- Text Notation

2  “a relationship between instances of classes (objects) that indicates some meaningful and interesting connection” (text, p. 150)

3  When “memory” of a relationship is required  (in a real world situation, not a software situation)  SalesLineItem instances are associated with a Sale instance. Otherwise, it would not be possible to reconstruct a sale, print a receipt, or calculate a sale total.

4  “Need to remember”  “Preserved for some duration”  Common Associations List (p.155)  “patterns” – e.g. Sale to SaleLineItem to Item.

5  Multiplicity defines how many instances of class A can be associated with one instance of class B

6  Name  Multiplicity (of Roles)  Multiple Associations  NOTE: Multiplicity depends on time Examples p.157

7

8 If we are selling a quantity of n of the same product (product:Product) then the SaleLine is associated with quantity n of that Product. But it is only associated with 1 Product. Note: this is sometimes modeled as a many to many association in a conceptual domain model to refer to the fact that a sale line can refer to many of the same product (e.g. 4 green peppers) BUT we are beyond that—as soon as we specify that product refers to an instance of the Product class, the multiplicity on the Product end should be a 1. Sells quantity of Contains A good association name helps clarify the association

9  In the domain Model  Relate conceptual classes with an association, NOT an attribute  Cashier to Register  NOT currentRegister attribute of Cashier

10

11  Attributes are shown several ways:  attribute text notation, such as currentSale : Sale.  association line notation  both together  Figure 16.3 shows these notations being used to indicate that a Register object has an attribute (a reference to) one Sale object.

12

13  NOTE: the information that follows is only for the purposes of answering the question “when would we use directional associations?”  Directional associations have arrows; regular associations do not

14  Directional associations are typically part of a Design Model (further on in the domain/design process); we would not usually show this in a domain model. (Larman, p.253) What this means: Order “knows” about OrderLine; OrderLine does not “know” about Order. In code, each Order class contains a reference to OrderLine objects (productOrderedSet). The OrderLine objects do not contain a reference to OrderLine.

15 public class Customer { private intcustID; private String custName; private Address address; private List contactSet; private Boolean isActive; public class Address { private int streetNum; private String streetName; private String city; private String postCode; private String province; private String country; public class Contact { private int contactID; private String name; private String phone;

16  A data type refers to objects for which unique identity is not important.  Common data types are primitive-oriented types such as:  Boolean, Date (or DateTime), Number, Character, String (Text), Time, Address, Color, Geometrics (Point, Rectangle), Phone Number, Social Security Number, Universal Product Code (UPC), SKU, ZIP or postal codes, enumerated types

17 Showing objects as attributes is typically reserved for the Design model (further on in the analysis and design process) but we are showing them here in SYS466 to aid in understanding.

18 In OO language implementation, objects will contain references to their object attributes. For example SaleLine will contain a reference to a Product object.

19 public class Order { private intorderID; private Customer customer; private List productOrderedSet; public class OrderLine { private int qtyOrdered; private Product product; public class Product { private int productID; private String productName; orders quantity of contains

20  Guideline: Use the attribute text notation for data type objects and the association line notation for others. Both are semantically equal, but showing an association line to another class in the diagram (as in Figure 16.3) gives visual emphasis—it catches the eye, emphasizing the connection between the class of objects on the diagram.

21  Slide material was taken from Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, Third Edition, By Craig Larman, Published by Prentice Hall, Pub. Date: October 20, 2004. Chapter 16


Download ppt "Domain Model—Part 3: Associations, Multiplicity and Attribute- Text Notation."

Similar presentations


Ads by Google