Presentation is loading. Please wait.

Presentation is loading. Please wait.

DOMAIN MODE: ASSOCIATIONS, MULTIPLICITY AND ATTRIBUTE-TEXT NOTATION SYS466.

Similar presentations


Presentation on theme: "DOMAIN MODE: ASSOCIATIONS, MULTIPLICITY AND ATTRIBUTE-TEXT NOTATION SYS466."— Presentation transcript:

1 DOMAIN MODE: ASSOCIATIONS, MULTIPLICITY AND ATTRIBUTE-TEXT NOTATION SYS466

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

3 When to show Associations 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 Finding Associations “Need to remember” “Preserved for some duration” Common Associations List (p.155)  “patterns” – e.g. Sale to SaleLineItem to Item.

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

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

7 Fig. 9.12 (p.152)

8 Object Attributes & Multiplicity 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 Guidelines In the domain Model  Relate conceptual classes with an association, NOT an attribute  Cashier to Register  NOT currentRegister attribute of Cashier

10 Fig. 9.22 (p.165)

11 Ways to Show UML Attributes: Attribute Text and Association Lines 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 Figure 16.3. Attribute text versus association line notation for a UML attribute.

13 Directional Associations: CAUTION 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? 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 Other Examples 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 Review: Data types 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 Object Attributes: Where & When? 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 Object Attributes: References In OO language implementation, objects will contain references to their object attributes. For example SaleLine will contain a reference to a Product object.

19 Example of Relationship between Order to OrderLine to Product 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 When to Use Attribute Text versus Association Lines for Attributes 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 Acknowledgement 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 MODE: ASSOCIATIONS, MULTIPLICITY AND ATTRIBUTE-TEXT NOTATION SYS466."

Similar presentations


Ads by Google