You are on page 1of 16

Domain Model: Adding Attributes

Chapter 12 Adding Attributes

OBJECTIVES

Learn how to identify and specify attributes in a domain model Learn to distinguish attributes correctly

ATTRIBUTES

After establishing classes based on the concepts of use case scenarios, the scenarios are examined to discover attributes Attributes are logical data values of an object

UML Attribute Notation

SALE

Attributes

Date: startTime: Time

Valid Attribute Types


Keep attributes simple Distinguish between conceptual and implementation perspectives Identify data types

Relate with associations, not attributes

NOT A SIMPLE ATTRIBUTE

CASHIER
Worse

NAME : current register

Better

CASHIER
NAME

1 USES

REGISTER
Number

Avoid Representing Complex Domain Concepts as Attributes

DESTINATION IS A COMPLEX CONCEPT

FLIGHT
Worse

DESTINATION

Better

1 Flies

Flight

Airport

Non Primitive Data Type


Represent what may be considered a primitive data type (such as a number or string) as a non primitive class if: It is composed of separate sections. phone number, name of person There are operations usually associated with it, such as parsing or validation. social security number It has other attributes promotional price could have a start date and end date
8

Non Primitive Data Type

It has a quantity with a unit. payment amount has a unit of currency It has abstraction of one or more types with some of these qualities. item identifier in the sales domain is a generalization of types such as Universal product code(UPC) or European Article Number(EAN)

Non primitive data Types


Applying these guidelines to the POS domain model yields the following analysis: The item identifier is an abstraction of various common coding codes schemes, including UPC-A, UPC-E, and the family of EAN schemes. These numeric coding schemes have subparts identifying the manufacturer, product and EAN

10

(continued)

The price and the amount attribute should be non primitive Quantity or Money classes because they are quantities in a unit of currency The address attribute should be a non primitive Address class because it has separate sections

11

If the attribute class is a data type, it may be

shown in the attribute box

Product Specification

ItemID

Store

Address

Product Specification

Store

Id: Item ID

address: Address

12

No attributes as Foreign Key


A simple attribute but being used as a foreign key to relate to another object.

CASHIER
Worse

Name: currentRegisterNumber

Better

CASHIER
NAME

1 USES 1

Register number

13

Modelling Attribute Quantites and Units


Payment Amount: Number Not useful

Payment

Has amount

Quantity Amount:Number

Is in

Unit

Payment Amount:Quantity

Quantities are pure data values, so suitable to show in attribute section

better

Payment Amount: Money

Variation: Money is a specialized Quantity whose unit is a currency

14

Domain Model Conclusion

A relatively useful model has been created for the domain of the POS application. A good domain model captures the essential abstractions and information required to understand the domain in context of current requirements, and aids people in understanding the domain its concepts ,

terminology, and the relationships.


15

Record -sale-of Described by

Product Specification Product Catalog


1 Contains 1

Description price ItemID

0..1

1 * Used by

Describes

Sales LineItem
1

Store Address name


1 Stocks

Item
1..

quantity
1.. Contain in 1 * 1.. Logs completed 1 Houses

Sale Register Date time


1 1 Captured on 1 1 1 Started by 1 1

Manager

Iniated by Paid By Record Sales on 1

Payment

Customer

Cashier

amount

A partial domain model

16