+ All Categories
Home > Documents > TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Date post: 31-Dec-2015
Category:
Upload: gervase-baker
View: 218 times
Download: 0 times
Share this document with a friend
Popular Tags:
46
TK2023 Object- Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING
Transcript
Page 1: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

TK2023 Object-Oriented Software Engineering

CHAPTER 5DOMAIN MODELLING

Page 2: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

INTRODUCTION

One of the steps in object-oriented analysis is the decomposition of a domain of interest into individual conceptual classes or objects (real-world objects).

An important artifact created in this step is a domain model (also known as conceptual model, domain object model and analysis object model).

Page 3: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

DOMAIN MODELS

A domain model is a visual representation of conceptual classes or real-world objects in a domain of interest.

In UML, a domain model is illustrated with a set of class diagrams in which no operations are defined.

It shows: conceptual classes (concepts / domain objects) associations between conceptual classes attributes of conceptual classes

Page 4: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Register

Item

Store

addressname

Sale

date time

Payment

amount

SalesLineItem

quantity

Stocked-in

*

Houses

1..*

Contained-in

1..*

Records-sale-of

0..1

Paid-by

1

1

1

1

1

1

0..1

1

Captured-on 4

conceptor domain object

association

attributes

Page 5: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

DOMAIN MODEL - A VISUAL DICTIONARY OF ABSTRACTIONS Note that the diagram in the previous slide

depicts an abstraction of the conceptual classes; details which are uninteresting to the modellers are ignored in the diagram.

The visual makes it easy to comprehend the discrete elements and their relationships. Thus, the domain model may be considered a visual dictionary of abstractions of the domain.

Page 6: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

DOMAIN MODELS DO NOT SHOW SOFTWARE COMPONENTS A domain model is a visualization of things in the

real-world domain of interest, not of software classes.

The following elements are not suitable in a domain model: software artifacts

responsibilities or methodsSale

dateprint()

POSApplet

Page 7: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

IDENTIFYING CONCEPTUAL CLASSES In iterative development, a domain model is

incrementally built over several iterations in the elaboration phase.

In each iteration, the domain model is limited to the prior and current scenarios under consideration.

It is okay to miss conceptual classes during the initial identification step. The domain model can be updated when they are discovered later (e.g. during design work).

Page 8: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

STRATEGIES FOR IDENTIFYING CONCEPTUAL CLASSES The following techniques can be used:

use a conceptual class category list identify noun phrases

Identify nouns and noun phrases in textual descriptions of a domain, and consider them as candidate classes or attributes.

Weakness: natural language is imprecise E.g. different noun phrases may represent the

same conceptual class or attribute.

Page 9: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

use analysis patterns Analysis patterns are existing partial

domain models created by experts

Page 10: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

CASE STUDY: PROCESS SALE Based on a simplified scenario of Process

Sale, the following candidate conceptual classes are identified using the first two techniques above:

Register ProductSpecification

Item SalesLineItem

Store Cashier

Sale Customer

Payment Manager

ProductCatalog

Page 11: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

REPORT OBJECTS

Should "receipt" be included in the domain model? One reason to exclude it:

A receipt is a report of a sale. In general, it is not useful to include conceptual classes that reports information that can be derived from other sources.

One reason to include it: A receipt has a special role in the domain. A customer

needs a receipt in order to return bought items.

Page 12: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

BUILDING A DOMAIN MODEL Apply the following steps:

1. Identify candidate conceptual classes related to the current requirements (use case) under consideration.

2. Represent those classes in a domain model.

3. Add associations necessary to record relationships for which there is a need to preserve some memory.

4. Add attributes necessary to fulfill the information requirements.

Page 13: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

SOME GUIDELINES

Use the vocabulary of the domain when naming conceptual classes and attributes. For example, in the library domain, the term

"Borrower" or "Patron" is used rather than "Customer"

You should not include conceptual classes in the problem domain not pertinent to the requirements. For the case study, "Pen" and "PlasticBag" should

not be included.

Page 14: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

You should not include things not in the problem domain. For example, "Flight" does not exist in the library

domain.

Page 15: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

ATTRIBUTE OR CONCEPTUAL CLASS? A common mistake when building a domain

model is to represent something as an atribute when it should have been a conceptual class.

Salestore

Sale StorephoneNumber

ORRepresent "store"as an attribute

Represent "store"as a conceptualclass

Page 16: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Use the following rule of thumb:

If we do not think of some conceptualclass X as a number or text in the realworld, then X is probably a conceptualclass and not an attribute.

Page 17: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Another example,

Flightdestination OR

Flight Airportname

Page 18: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Consider our case study. Let's assume that: An "Item" represents a physical item in a store. An "Item" has a description, price and itemID,

which are not recorded elsewhere. Everyone working in the store has amnesia. Every time a real physical item is sold, a

corresponding software object "Item" is deleted from the computer memory.

“Rice Brand X”RM0.6011234

“Rice Brand X”RM0.6011234

“Rice Brand X”RM0.6011234

“Rice Brand X”RM11.00U110-134

“Rice Brand X”RM11.00U110-134

“Rice Brand X”RM11.00U110-134

SPECIFICATION OR DESCRIPTION CONCEPTUAL CLASSES

Page 19: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Problems: Information about the price of a "Rice Brand X"

product is lost if the shop is sold out of "Rice Brand X" products.

Space inefficiency as the price and itemID of "Rice Brand X" are duplicated for every "Item" instance of the same product.

This illustrates the need for conceptual classes that are specifications or descriptions of other things.

Page 20: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Example:

ItemdescriptionpriceserialNumberitemID

ItemserialNumber

ProductSpecificationdescriptionpriceitemID

*1

Describes

1 *

Page 21: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Add a specification or description conceptual class when: There needs to be a description about an item or

service, independent of the current existence of any examples of those items or services.

Deleting instances of things they describe results in a loss of information that needs to be maintained.

It reduces redundant or duplicated information.

Page 22: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Another example:

Airportname

Flightdatetime

FlightDescriptionnumber

1

*

1

*Describes-flights-to

1*

Described-by

* 1

Airportname

Flightdatenumbertime

* 1

Flies-to

1*

Page 23: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

CASE STUDY: INITIAL DOMAIN MODEL

ItemRegister Store Sale

SalesLineItem Cashier Customer Manager

Payment ProductCatalog ProductSpecification

Based on the candidate conceptual classes identified previously, an initial domain model can be produced as follows:

Page 24: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

ASSOCIATIONS

An association is a relationship between classes that indicates some meaningful and interesting connection.

Register Sale

11

Records-current

1 1

Page 25: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

THE UML ASSOCIATION NOTATION

Sale Cashier

1** 1

Initiates

associations in domain models areinherently bidirectional

reading direction arrow - no special meaning, it's just to aid reading

multiplicity expressions

"Cashier initiates Sale"

Page 26: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

CRITERIA FOR USEFUL ASSOCIATIONS We need to be selective when adding

associations to a domain model. There can be n*(n-1) possible associations in a

domain model with n different conceptual classes. Too many associations in a domain model can

make it difficult to understand which defeats its purpose as a communication tool.

Page 27: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Associations worth adding to a domain model are usually those for which knowledge of the relationship needs to be preserved for some duration (even for a millisecond).

For example,

The SalesLineItem objects associated with a Sale object need to be remembered; otherwise, it would not be possible to print a receipt, for instance.

Sale SalesLineItem

1..*11 1..*

Contains

Page 28: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Also, include associations as suggested by the requirements (use cases).

Sale Manager

1** 1

Page 29: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

FINDING ASSOCIATIONS

Consider including the following associations in a domain model: Associations for which knowledge of the

relationship needs to be preserved for some duration ("need-to-know" associations).

Associations derived from the Common Associations List. Give priority to these categories

A is a physical or logical part of B A is physically or logically contained in/on B A is recorded in B

Page 30: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

USEFUL GUIDELINES

Focus on "need-to-know" associations. It is more important to identify conceptual

classes than to identify associations. Too many associations tend to confuse a

domain model. Avoid showing redundant or derivable

associations.

Page 31: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Example:

SalesLineItem

Item

0..1

1..*

Sale1 1..*1 1..*

Contains

0..1

1..*

Records-Sale-Of

1..*

0..10..1

1..*

Involves

DERIVABLE

Page 32: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

MULTIPLICITY

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

Store Item*1

Stocks

*1

association multiplicity

Page 33: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

zero or more;"many"

one or more

one to 40

exactly 5

T

T

T

T

*

1..*

1..40

5

T3, 5, 8

exactly 3, 5, or 8

Page 34: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Note that the multiplicity value is dependent on our interest as a modeler and software developer.

Consider the following possibilities:

husband

Person

1

1..4

Married-to

wife

1

Person

1

Married-to

wife

1

1husband

Person

1

1..*

Married-to

wife

1husband

Page 35: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

NAMING ASSOCIATIONS The name of an association should be a verb or

a verb phrase. Ensure that it creates a sequence that is readable and meaningful in the model context. By convention, the default direction is left to right or top to bottom.

Airline

Flight PlanePerson

Employs

Supervises

Assigned-to Assigned-to

"Airline Employs Person"

"Plane Assigned-to Flight"

Page 36: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

MULTIPLE ASSOCIATIONS BETWEEN TWO CLASSES It is not uncommon to have multiple

associations between two conceptual classes. Consider the following:

Both associations need to be shown separately as they indicate distinctly different relationships.

Flight Airport1* Flies-to

1* Flies-from

1

1*

*

Page 37: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

ASSOCIATIONS AND IMPLEMENTATIONS Associations in a domain model represent

relationships that are meaningful in the real world.

Not all associations in a domain model need to be implemented in software.

Page 38: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

DOMAIN MODEL FOR POS SYSTEM (WITH ASSOCIATIONS)

Register

ItemStore

Sale

Payment

SalesLineItem

CashierCustomer

ProductCatalog

ProductSpecification

Stocks

*

Houses

1..*

Used-by

*

Contains

1..*

Describes

*

Captured-on

Contained-in

1..*

Records-sale-of

0..1

Paid-by Is-for

Logs-completed

*

3 Works-on

1

1

1 1..*

1

1

1

1

1

1

1

0..1 1

1--

1

1

Page 39: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

ADDING ATTRIBUTES

Besides associations, we also need to identify attributes of conceptual classes that are needed to satisfy the information requirements of the current scenarios under development.

Page 40: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

ATTRIBUTE

An attribute is a logical data value of an object.

A domain model should include attributes for which the requirements (such as use cases) suggest or imply a need to remember information.

For example, a receipt normally includes the date and time of sale.

Page 41: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

NOTATION FOR ATTRIBUTES

The type of an attribute is optional.

Saledate : Datetime attributes

Page 42: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

GUIDELINES FOR IDENTIFYING ATTRIBUTES The attributes in a domain model should

preferably be simple attributes or data types.Examples of attribute types: Boolean, Date, Number, String (Text), Time Address, Colour, PhoneNumber,

SocialSecurityNumber, UniversalProductCode, Postcode

Page 43: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Consider the following:

Cashier

namecurrentRegister

Cashier

name

Register

numberWorks-on

1 1

This is not a "simple"attribute

Page 44: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

Relate conceptual classes with an association, not with an attribute.

Flight

destination

destination is acomplex concept

AirportFlight

* 1* 1

Flies-to

Page 45: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

ATTRIBUTES AS FOREIGN KEYS Do not use attributes as foreign keys to relate

conceptual classes (as typically done in relational database designs).

Use associations to relate those classes.

Register

numbercashierID

Register

number

Cashier

name11

Works-on

11

Page 46: TK2023 Object-Oriented Software Engineering CHAPTER 5 DOMAIN MODELLING.

DOMAIN MODEL FOR POS SYSTEM

Register

ItemStore

Sale

Payment

SalesLineItem

CashierCustomer

ProductCatalog

ProductSpecification

Stocks

*

Houses

1..*

Used-by

*

Contains

1..*

Describes

*

Captured-on

Contained-in

1..*

Records-sale-of

0..1

Paid-by Is-for

Logs-completed

*

3 Works-on

1

1

1 1..*

1

1

1

1

1

1

1

0..1 1

1--

1

1

quantity

dateTimetotal

amountTendered

nameaddress

number

itemIDdescriptionprice

number


Recommended