64
OO Domain Modeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences Department of Computer Science Dr. Doaa Sami Khafaga

OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Embed Size (px)

DESCRIPTION

What is a Domain Model? ● Use cases looked at the system’s environment (actors) and the system’s external behavior. ● Use cases consider the system as a black box and help us understand how the system as a whole interacts with the outside word. ● Now we turn to consider the inside of the system. We do this by building the domain model, which shows what the black box (the system) encloses. ● uses cases elaborate the system’s behavioral characteristics (sequence of stimulus-response steps), ● domain model gives details of the systems structural characteristics (system parts and their arrangement) S.H 2009 Software EngineeringOO Domain Modeling

Citation preview

Page 1: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

OO DomainModeling With UML Class Diagrams and

CRC CardsChapter 6

Princess Nourah bint Abdulrahman UniversityCollege of Computer and Information Sciences

Department of Computer Science

Dr. Doaa Sami Khafaga

Page 2: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Objectives

The main objective of this chapter is to know: how to properly use the most essential features of UML class diagrams, and the typical problems you will encounter when modeling with class diagrams.

In this chapter we:

● Introduce the evolutionary approach for building classes

● Explain how to identify objects and attributes of classes

● Describe the technique of CRC ‘Class Responsibility and Collaborator’

● Explain how classes are related in a class diagram

● Explain generalization, association, aggregation and composition

● Introduce object diagramsS.H2009

Software Engineering OO Domain Modeling

Page 3: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

What is a Domain Model?● Use cases looked at the system’s

environment (actors) and the system’s external behavior.

● Use cases consider the system as a black box and help us understand how the system as a whole interacts with the outside word.

● Now we turn to consider the inside of the system. We do this by building the domain model, which shows what the black box (the system) encloses.

● uses cases elaborate the system’s behavioral characteristics (sequence of stimulus-response steps),

● domain model gives details of the systems structural characteristics (system parts and their arrangement)

S.H2009

Software Engineering OO Domain Modeling

Page 4: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

What is a Domain Model?

● uses cases elaborate the system’s behavioral characteristics (sequence of stimulus-response steps),

● domain model gives details of the systems structural characteristics (system parts and their arrangement)

● The next step is to model the inside of the system. We do this by building the domain model, which shows what the black box (the system) encloses.S.H

2009

Software Engineering OO Domain Modeling

Page 5: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

What is a Domain Model?

● Illustrates meaningful concepts in the problem domain.

● Usually expressed in the form of static diagrams (in Rational this implies a high-level class diagram).

● Is a representation of real-world things; not software components (of the system under development).

● No operations are defined or specified in the conceptual model.

● Should show concepts, associations between concepts, and attributes of concepts.

● Serves as a source of software objects.

S.H2009

Software Engineering OO Domain Modeling

Page 6: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

What is a Domain Model?

Objectives

● identify concepts related to current development cycle requirements

● create initial conceptual model

● Identify attributed

● add specification concepts

S.H2009

Software Engineering OO Domain Modeling

Page 7: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

What is a Domain Model?

S.H2009

Software Engineering OO Domain Modeling

Page 8: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

What constitutes a good model?

A model should● use a standard notation● be understandable by clients and users● lead software engineers to have insights

about the system● provide abstraction.

Models are used:● to help create designs● to permit analysis and review of those

designs● as the core documentation describing

the system.S.H2009

Software Engineering OO Domain Modeling

Page 9: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

From Use Cases to: Objects, Attributes, Operations (methods) -“evolutionary ”

S.H2009

Software Engineering OO Domain Modeling

Page 10: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Building the Domain Model

A useful strategy for building a domain model is to start with:

● the “boundary” concepts that interact directly with the actors

● and then identify the internal concepts

S.H2009

Software Engineering OO Domain Modeling

Page 11: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Domain Model Relationships

Domain Model

Interaction Diagrams

Dynamic Behavior

Conceptual Class DiagramClasses, attributes, associations

Domain objects

Use Case Model

Functional Requirements

Define terms

Glossary

S.H2009

Software Engineering OO Domain Modeling

Page 12: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Steps to create a Domain Model

Steps

● Identify Candidate Conceptual classes

● Draw them in a Domain Model

● Add associations necessary to record the relationships that must be retained

● Add attributes necessary for information to be preserved

S.H2009

Software Engineering OO Domain Modeling

Page 13: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Find conceptual classes

S.H2009

Software Engineering OO Domain Modeling

Page 14: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Use a category list

● Finding concepts using the concept category list :

● Physical objects: register, airplane, blood pressure monitor

● Places: airport, hospital

● Catalogs: Product Catalog

● Transactions: Sale, Payment, reservation

S.H2009

Software Engineering OO Domain Modeling

Page 15: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Identify conceptual classes from noun phrases

● Finding concepts using Noun Phrase identification in the textual description of the domain .

● Noun phrases may also be attributes or parameters rather than classes:● If it stores state information or it has multiple

behaviors, then it’s a class● If it’s just a number or a string, then it’s

probably an attributeS.H2009

Software Engineering OO Domain Modeling

Page 16: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Identifying objects

S.H2009

Software Engineering OO Domain Modeling

Page 17: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Identifying Operations ‘methods’

S.H2009

Software Engineering OO Domain Modeling

Page 18: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Objects

S.H2009

Software Engineering OO Domain Modeling

Page 19: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Example: Identify conceptual classes from noun phrasesConsider the following problem description, analyzed for Subjects, Verbs, Objects:

S.H2009

Software Engineering OO Domain Modeling

The ATM verifies whether the customer's card number and PIN are correct.

SC V R O O A O AIf it is, then the customer can check the account balance, deposit cash, and withdraw cash.

S R V O A V O AV O A

Checking the balance simply displays the account balance.S M O A V O A

Depositing asks the customer to enter the amount, then updates the account balance.

M S V O R V OA V OAWithdraw cash asks the customer for the amount to withdraw; if the account has enough cash,

S M A O V O R OA V S C V O A

the account balance is updated. The ATM prints the customer’s account balance on a receipt.

O A V C S V O A

O

Analyze each subject and object as follows:● Does it represent a person performing an action? Then it’s an actor, ‘R’.● Is it also a verb (such as ‘deposit’)? Then it may be a method, ‘M’.● Is it a simple value, such as ‘color’ (string) or

‘money’ (number)? Then it is probably an attribute, ‘A’.

●Which NPs are unmarked? Make it ‘C’ for class. Verbs can also be classes, for example:● Deposit is a class if it retains state

information

Page 20: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Mapping parts of speech to object model components [Abbott, 1983]

S.H2009

Software Engineering OO Domain Modeling

Part of Speech

Model Component

Examples

Proper noun Instance AliCommon noun Class Student,

Customer,..Doing verb Operation Buy, check,..Being verb Inheritance Is a kind of, is

one of eitherHaving verb Aggregati

on (Composition)

Has, consists of, includes

Modal verb Constraints Must beAdjective attributes

Attributes 3 years old

Page 21: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Example: a typical description

S.H2009

Software Engineering OO Domain Modeling

Page 22: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Mapping parts of speech to object model components

S.H2009

Software Engineering OO Domain Modeling

Page 23: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Identify conceptual classes from noun phrases: POS

● Examine use case descriptions.● Example: Process Sale use case:

● Main success scenario:● Customer arrives at a POS checkout counter.● Cashier starts a new sale.● Cashier enters an item ID.● System records sale line item. It then presents a

description of the item, its price, and a running total.

● ….● ….

● Possible source of confusion: Is it an attribute or a concept?

● If X is not a number or a text then it probably is a conceptual class.S.H

2009

Software Engineering OO Domain Modeling

Page 24: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Example: Initial POS domain model

S.H2009

Software Engineering OO Domain Modeling

SalesLineItem Item

Sale

Register

StorePayment

Page 25: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Class and Class diagram

• Class naming: Use singular namesbecause each class represents a generalized version of asingular object.

• Class diagrams are at the core of OO Engineering.

• Things naturally fall into categories (computers, automobiles, trees...).

• We refer to these categories as classes.

• An object class is an abstraction over a set of objects with common:

•attributes (states)•and the services (operations)

(methods) provided by each object

• Class diagrams provide the representations used by the developers.

S.H2009

Software Engineering OO Domain Modeling

Page 26: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Example: Initial POS domain model

S.H2009

Software Engineering OO Domain Modeling

Page 27: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Example: Initial Domain model of the Monopoly Game

S.H2009

Software Engineering OO Domain Modeling

Page 28: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Example: Domain model of the Monopoly Game

S.H2009

Software Engineering OO Domain Modeling

Page 29: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Agile modeling style

S.H2009

Software Engineering OO Domain Modeling

Page 30: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

S.H2009

Software Engineering OO Domain Modeling

Page 31: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

S.H2009

Software Engineering OO Domain Modeling

Page 32: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

S.H2009

Software Engineering OO Domain Modeling

Page 33: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

S.H2009

Software Engineering OO Domain Modeling

Page 34: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

S.H2009

Software Engineering OO Domain Modeling

Page 35: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

S.H2009

Software Engineering OO Domain Modeling

Page 36: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

S.H2009

Software Engineering OO Domain Modeling

Page 37: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

S.H2009

Software Engineering OO Domain Modeling

Page 38: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Class or Attributes

S.H2009

Software Engineering OO Domain Modeling

Page 39: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Class or Attributes

S.H2009

Software Engineering OO Domain Modeling

Page 40: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Description Class

S.H2009

Software Engineering OO Domain Modeling

Page 41: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Associations

S.H2009

Software Engineering OO Domain Modeling

Page 42: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Associations

S.H2009

Software Engineering OO Domain Modeling

Page 43: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Association, aggregation and composition

S.H2009

Software Engineering OO Domain Modeling

Page 44: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Association between classes Who does What

S.H2009

Software Engineering OO Domain Modeling

Page 45: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

When to show association

S.H2009

Software Engineering OO Domain Modeling

Page 46: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Associations and implementation

S.H2009

Software Engineering OO Domain Modeling

Page 47: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Association Notation

S.H2009

Software Engineering OO Domain Modeling

Page 48: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Association Notation

S.H2009

Software Engineering OO Domain Modeling

Page 49: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Naming association

S.H2009

Software Engineering OO Domain Modeling

Page 50: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Applying UML: multiplicity

S.H2009

Software Engineering OO Domain Modeling

Page 51: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Multiplicity values

S.H2009

Software Engineering OO Domain Modeling

Page 52: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Applying UML: multiplicity

S.H2009

Software Engineering OO Domain Modeling

Page 53: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Applying UML: multiplicity

S.H2009

Software Engineering OO Domain Modeling

Page 54: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Multiple association between two classes

S.H2009

Software Engineering OO Domain Modeling

Page 55: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Find association

S.H2009

Software Engineering OO Domain Modeling

Page 56: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Find association

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

● Other associations● A uses or manages or controls B (Pilot -airplane)● A owns B (Airline -airplane)

● Each of the two ends of an association is called a role. Roles have● name● multiplicity expression● navigabilityS.H

2009

Software Engineering OO Domain Modeling

Page 57: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Example: POS Domain Model

S.H2009

Software Engineering OO Domain Modeling

Page 58: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Example: Monopoly Game Partial Domain Model

S.H2009

Software Engineering OO Domain Modeling

Page 59: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Attributes

● Attribute - is a logical data value of an object

● Include the following attributes in a conceptual model● those for which the requirements suggest

or imply a need to remember information

● For example:● Sale needs a dateTime attribute● Store needs a name and address.

S.H2009

Software Engineering OO Domain Modeling

Page 60: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Attributes: UML Notation

S.H2009

Software Engineering OO Domain Modeling

Page 61: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Suitable attribute types

S.H2009

Software Engineering OO Domain Modeling

Page 62: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Data types as attributes

S.H2009

Software Engineering OO Domain Modeling

Page 63: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Attributes are NOT foreign keys

S.H2009

Software Engineering OO Domain Modeling

Page 64: OO DomainModeling With UML Class Diagrams and CRC Cards Chapter 6 Princess Nourah bint Abdulrahman University College of Computer and Information Sciences

Generalization

S.H2015

Software Engineering OO Domain Modeling