domain modelling
DESCRIPTION
gTRANSCRIPT
-
Domain Modelling
Sunday, 23 September 12
-
Part 1: Conceptual Classes
Sunday, 23 September 12
-
What is a Domain Model
a diagram (or set of diagrams) which represents real world domain objects
conceptual classes not a set of diagrams describing software classes, or
software objects with responsibilities
Sunday, 23 September 12
-
Why make a Domain Model?
to understand what concepts need to be modelled by our system, and how those concepts relate
a springboard for designing software objects
Sunday, 23 September 12
-
What should it show?
conceptual classes associations between conceptual classes attributes of conceptual classes
Sunday, 23 September 12
-
Example
from Ch 9 Applying UML & Patterns (Larman 2004)
Sunday, 23 September 12
-
What should it avoid?
software artifacts such as the User Interface or databases
responsibilities and methods these should appear in sequence and class diagrams
Sunday, 23 September 12
-
ExampleInclude:
Sale
datetime
Avoid:
from Ch 9 Applying UML & Patterns (Larman 2004)
Sunday, 23 September 12
-
Identifying Conceptual Classes
try to represent all the objects in the domain, whether they are:
tangible objects product, book
intangible concepts course, route
people student, lecturer
places city, classroom
events sale, enrolment
...or something else booking policy
Sunday, 23 September 12
-
Noun-Phrase Identification
one way to identify conceptual classes from client documents or use case descriptions note that this wont capture everything
Sunday, 23 September 12
-
Example1. The user requests a list of courses currently available for enrolment.
2. The system retrieves the list of courses available and displays the list to the user.
3. The system provides the user with the opportunity to select a course or to exit the use case.
4. The user selects a course for which he or she wants to enrol.
5. The system retrieves the details for the chosen course, including the course outline, timetable and eligibility requirements and displays the details to the user.
6. The user confirms that he or she wants to enrol for the course.
7. The system checks that the user has taken and passed the pre-requisite courses for the chosen course.
8. The system checks that the user is not already enrolled on a course whose timetable clashes with the chosen course.
9. The system records that the user is now enrolled to the chosen course, updating the list of students.
10. The system informs the user that enrolment has been successful, and offers the student the opportunity to receive proof of enrolment.
...
student
Sunday, 23 September 12
-
Maintain the context of the problem domain
where a concept already has a name, use it dont include concepts from beyond the domains
boundary
dont add concepts that dont belong model actual concepts rather than over-specific
versions of them
exhaust pipe, brake calliper, windshield - too specific auto part (with an attribute of type) - better
Sunday, 23 September 12
-
Object or Attribute
If we do not think of come conceptual class X as a number or text in the real world, X is probably a conceptual class, not an attribute.
Craig Larman in Applying UML & Patterns (2004)
Sunday, 23 September 12
-
Examples
Sale
store
Sale Store
location
Flight
Airport
Flight Airport
name
both Store and Airport represent concepts of interest in their own right, so we model them as conceptual classes rather than attributes
from Ch 9 Applying UML & Patterns (Larman 2004)
Sunday, 23 September 12
-
Adding Specification or Description Conceptual Classes sometimes we need to separate out the description of
a concept from the concept itself, so that even if no instances of the concept exist at a given point in time, its description will still be present in the system
doing this can reduce unnecessary redundancy in recording information when we move into design and build
Sunday, 23 September 12
-
Examples
from Ch 9 Applying UML & Patterns (Larman 2004)
Sunday, 23 September 12
-
Examples
from Ch 9 Applying UML & Patterns (Larman 2004)
Describes-flights-to
Sunday, 23 September 12
-
Domain versus Design Models
from Ch 9 Applying UML & Patterns (Larman 2004)
Sunday, 23 September 12
-
Part 2: Associations
Sunday, 23 September 12
-
Associations
we should model the important relationships between conceptual classes
not every relationship, that would create clutter and confusion
not too few, we want a useful model for each association, provide:
a short yet meaningful text label the multiplicity
Sunday, 23 September 12
-
Example
Student
name
Course
title
takes
Lecturer
name
teaches
Sunday, 23 September 12
-
Multiplicity
how many instances of class A can be associated with a single class B at a particular point in time
Student
name
Course
title
takes
Lecturer
name
teaches
8..* 0..3
0..3
1
Sunday, 23 September 12
-
Types of Multiplicity
* many (zero or more)
1..* many (one or more)
0..3 zero to three
1..3 one to three
8 exactly 8
2,4,6 exactly 2, 4 or 6
Sunday, 23 September 12
-
Many-to-Many?
where possible try to make all associations 1-to-n (or 0-to-n), since this will help to identify deeper concepts in the domain
Student
name
Course
title
Lecturer
name
teaches 0..3
1
is upon 8..*0..3
Enrolment
name11
makes
Sunday, 23 September 12
-
Identifying Associations
one approach is to list for each conceptual class how it relates to others:each Student... takes zero to three courses
has exactly one timetable...
each Lecturer... teaches zero to three coursesbelongs to one or two departments...
each Course... is taught by exactly one lectureris taken by 8 to many students
Sunday, 23 September 12
-
Multiple & Reflexive Associations
can two conceptual classes have multiple associations with each other, and can a class associate with itself?
Sales Rep
name
Area
title
makes sales in 1..* 1..*
manages 1 1
Course
titleis pre-requisite for
*
*
yes,
and yes
but in each case it might be better to use generalisation and/or to add further conceptual classes to the model
Sunday, 23 September 12
-
Generalisation
sometimes conceptual classes are (sub) types of another class:
Student
student id
Course
title
takes
Lecturer
employee #
teaches
8..* 0..3
0..3
1
Person
name
Sunday, 23 September 12
-
Composition and Aggregation
Chess Board Square
colourconsists of 641
Student
name
8..*0..3Class List
contains
without the chess board, the square wouldnt exist...
...but without the class list the student would
Composition:
Aggregation:
Sunday, 23 September 12
-
Part 3: Attributes
Sunday, 23 September 12
-
Object or Attribute(reminder)
If we do not think of come conceptual class X as a number or text in the real world, X is probably a conceptual class, not an attribute.
Craig Larman in Applying UML & Patterns (2004)
Sunday, 23 September 12
-
No Foreign Keys
Student
student idtimetable
TimetableStudent
student id
Why avoid listing foreign keys as attributes?- because there may be more than one way to implement an association in design
fails the simple number or text test
better:
Sunday, 23 September 12
-
To conclude
find many associations between the conceptual classes, but only model the useful ones
take care with multiplicity domain modelling can be taken further - such as using
association classes and packages - but the techniques and artifacts demonstrated here are sophisticated enough for you to analyse and model most problem domains
Sunday, 23 September 12
-
References & Further Reading
base structure and figures taken from: Applying UML & Patterns (Larman 2004), Chapters 9, 10,
11 & 27
a different approach (just skipping to class diagrams): Object-Oriented Systems Analysis and Design (Bennett et
al, 2nd Edition, 2002), Chapter 7
Sunday, 23 September 12