Unit 3: From Domain Modelling To Requirements
Unit 3: From Domain Modelling To Requirements
1
This unit looks at how modelling can help with the process of
capturing and documenting requirements.
UML activity diagrams are used to model workflows and
understand business processes in a domain.
UML use cases are used to record and document chunks of
functionality required by the users of a system, and the
interactions with that system.
You will explore how activity and use case modelling can be used,
in consultations with the users, to help the developer to identify
which interfaces are needed to complete required activities, and to
build prototypes for rapid feedback
Note that: All SAQs and Exercises in this unit are required.
2
Section 1: Introduction
In this unit, we study some well established techniques for capturing and
documenting user requirements and system behaviour.
We start by looking at the business domain as the context in which a
software solution may be applied.
In this module we will discuss enough of the business to understand the
context and the requirements for a system within that context.
Section 2 introduces the concepts of business rules and business
processes, together with activity diagrams as the technique for modelling
these processes.
Sections 3 and 4 of this unit introduce use cases as a tool for
requirements.
Finally, in Section 5, we consider how prototyping can help with
requirements engineering.
3
Business rules constrain how a business is run.
There is a clear distinction between the business processes
and the constraints.
Example, in a car rental company:
- renting a car (business process);
- the car allocated is the lowest mileage car that is available in the
chosen group. (business rule)
Business rules need to be identified and recorded:
1. to provide quick and easy access whenever there is a change.
2. business rules are the basis of decision making
Business rules that apply to the whole business should be
represented separately from project specific models.
4
Section 2: Business rules and business processes
5
Section 2: Business rules and business processes
6
Section 2: Business rules and business processes
7
Section 2: Business rules and business processes
8
Section 2: Business rules and business processes
9
Section 2: Business rules and business processes
10
Section 2: Business rules and business processes
Figure 1 in the next slide shows an activity diagram that models the process of making a hot drink of
instant coffee with milk. It shows one way of preparing a cup of coffee. ‘… Pour boiled water into a cup
containing coffee. Add milk. Drink coffee.’
11
Section 2: Business rules and business processes
The basic elements of an activity diagram are activities and transitions. The
completion of an activity triggers an outgoing transition. Similarly, once the
incoming transition has been triggered an activity may commence.
In an activity diagram, activities are shown as rounded boxes; transitions are
shown as lines with arrows.
There are two predefined activities, start and stop, which is represented as filled
circles, a diagram may include more than one stop node if it makes it clearer.
The Figure shows two synchronisation bars, denoted by thick horizontal lines.
The upper one denotes a fork and the lower one a join. The upper bar allows for
separate activities to be carried out in parallel, so between the two
synchronisation bars the two separate strands can be performed concurrently.
In UML, a note (with annotation) is shown as a rectangle with the top right-hand
corner folded down.
A dashed line is used to attach the note to the model element to which it refers.
13
Section 2: Business rules and business processes
Example 2: Redraw the activity diagram of preparing a cup coffee so that it allows to
check if cup is clean continue the process, if not wash the cup
In Figure 2, the flow between activities is constrained with a Boolean test, known
as a guard, which is represented inside a pair of square brackets.
Each of the transitions leaving the first decision diamond has a guard to
determine which path should be taken under a given condition.
One outgoing transition should always be taken – this means that exactly one of
the relevant guards must always evaluate to true.
A diamond shape is also used as a merge node, which brings together
alternative mutually exclusive flows, as shown in Figure 2.
A merge node will be reached only by one of the alternative flows and has a
single outgoing flow.
An activity has only one transition into and out of it.
This is enforced by ‘decision’ and ‘merge’ nodes for alternative outgoing and
incoming transitions, and by synchronisation bars for concurrent outgoing (fork)
and incoming (join) transitions.
15
Section 2: Business rules and business processes
Example 3: Redraw the activity diagram of figure 1 to allow the choice between coffee
with milk and coffee without milk.
Example 4: Draw an
activity diagram to
illustrate the preparation
of a pot of tea, which
replaces the activities
relating to coffee shown
in Figure 1. The new
diagram should allow the
choice of both milk and
sugar when the tea is
poured.
Example-5
When borrowing books, a member is expected to wait in queue, then to hand their
chosen books to the librarian, who records each new loan before issuing the books
to the member. After that the librarian will prepare for next member in the queue.
When a book is on loan to a member, it is associated with that member: possession
of the book passes from the library to the member for a defined period. The normal
loan period for each book is two weeks. If the member fails to bring the book back
on or before the due date, the library imposes a fine."
18
Section 2: Business rules and business processes
Example-5 (contd.)
A. What are the business process and business rules in the above
system.
Business processes: find book on a shelf; wait in the queue; issue a
book, and return a book.
Business rules:
- There is a limit to the number of books a member can take out.
- A loan is for a period that is normally two weeks.
- Late returns incur a fine.
19
Section 2: Business rules and business processes
Activity diagram for issuing a copy of a book (using two swimlanes separated by a vertical line)
Swinlanes
21
Section 2: Business rules and business processes
Example 6: Assume you have the below activity diagram of returning a copy of a book to library.
List the sequence of activities with showing roles of people.
22
Section 2: Business rules and business processes
Example 7:
Use figure 5 and 6 to produce a single activity diagram that models the
borrowing and returning of books, based on the following assumptions:
23
Section 2: Business rules and business processes
Example 7 Solution
24
Section 2: Business rules and business processes
Activity diagrams Symbols (contd.)
25
Section 2: Business rules and business processes
Summary of section
Business processes define the activities that take place, their ordering
and the roles required to carry them out.
Business processes can be represented by activity diagrams.
Activity diagrams are a way of understanding the workflows within the
business domain.
They allow you to record the things that users do or want to do.
From a simple problem description, you can show the flow of control
between the activities that are carried out by different roles.
26
Section 3: Simple use case models
27
Section 3: Simple use case models
28
Section 3: Simple use case models
29
Section 3: Simple use case models
Representing requirements;
30
Section 3: Simple use case models
31
Section 3: Simple use case models
System Boundary
The system boundary
determines the scope of the
system.
It distinguishes between internal
and external components.
The external components are
actors and the internal
components are the use cases.
In UML it is optional to use system
boundary notation.
A solid box drawn around the use
cases with the actors located
outside it represents the system
boundary.
We use system boundary notation Figure : A use case diagram for a hotel chain, showing the
when the system is complex and system boundary
includes several subsystems.
33
Section 3: Simple use case models
The guest wants to reserve a double room at the Hotel for 14 July. A
double room is available for that date, and the reservation is done.
Unsuccessful scenario
The guest wants to reserve a single room at the Hotel for the first week of
August. There is no single room that is free for seven days in August, but
there is one room available for four days and another one for the following
three days. The system presents that option to the guest, who rejects it.
34
Section 3: Simple use case models
Example 9: What pre and post condition you can obtain from the below
description of check in process?
Upon arrival, each guest provides the reservation number for his or her
reservation to the hotel’s receptionist, who enters it into the software system.
The software system reveals the details of that reservation so that each guest
can confirm them. The software system allocates an appropriate room to that
guest and opens a bill for the duration of the stay. The receptionist issues a
key for the room.
Solution
Precondition: There must be a reservation for the guest, and there must be
at least one room available (of the desired type), and the guest must be able
to pay for the room.
Post-condition: The guest will have been allocated to a room for the period
identified in the reservation, the room will have been identified as being in use
for a specific period, a bill will have been opened for the duration of the stay,
and a key will have been issued.
35
Section 3: Simple use case models
The requirements of a
use case can be
captured through
either:
1. a written statement;
2. more formally, the use
of pre- and post-
conditions.
A textual description of
the “make reservation”
use case in the hotel
domain is shown in the
table 1
36
Section 3: Simple use case models
Use case and a Scenario
37
Section 3: Simple use case models
38
Section 3: Simple use case models
39
Section 3: Simple use case models
40
Section 3: Simple use case models
41
Section 3: Simple use case models
In this section, you saw how use case diagrams help you define what a proposed system
should do from a user’s perspective. Use case can also provide a basis for a contract
between the customer and the developer because:
use case models are used to drive the work to be done in software development
from a simple problem description, it is possible to draw a use case model that can be
understood by people who are unfamiliar with UML
each use case should lead to a result that brings some observable value to at least one of
its actors
the requirements of a use case can be captured through either a written statement or, more
formally, the use of pre- and postconditions
detailed software requirements can be generated from each step of a scenario of a use case
scenarios, which are particular sequences of possible actions within a given use case, can
be walked through to determine the extent to which customer’s expectations will be met
‘walkthroughs’ of scenarios help with the validation of the architecture of a system
use cases can be used in an agile approach.
42
Section 4: More details on use case models
In the first stage you draw a simple use case, then when you
gain extra details you can refine it.
UML provides a notation to use generalisation between
actors.
When two actors share the same behaviour (interacting with
the same use cases) and one of them has some extra
behaviour, then the common behaviour can be associated
with a generalised actor and the more specific behaviour with
the specialised actor.
For example, in the hotel system both the receptionist and
the guest are allowed to make reservation.
◦ Guest can make reservation through online system;
◦ the receptionist can do reservation on behalf of guest when a guest do
reservation through phone or a fax.
43
Section 4: More details on use case models
44
Section 4: More details on use case models
Use cases can be related to one another. There are two very common and
important forms of relationship between use cases: inclusion and extension.
Inclusion: This is when two or more use cases have a common area of
functionality that can be factored out as a distinct use case.
The new use case can be used by each of the original use cases, so avoiding
duplication.
Extension: This is when a use case has a main success scenario but also
alternative scenarios which demand a variation on the original use case –
different or additional actions.
Each variation can be separated out as a use case that is distinct from but
related to the original use case.
An extension is conditional while an inclusion is not.
In UML we use «include» and «extend» stereotypes for representing inclusion
and extension.
45
Section 4: More details on use case models
UML is extensible.
◦ It is possible to add to its basic language.
One way this can be done is by adding stereotypes.
A stereotype is a way of attaching extra classifications to a model.
They can be used to specialize a UML element of any kind.
◦ For example, a class can be given the stereotype «abstract».
A UML stereotype name is always enclosed between double angle
brackets «...», called guillemets.
For instance, we could add a stereotype «tm354» but we would need to
agree on its meaning.
Stereotypes can be user-defined.
◦ We can add our own, but we need to agree on its meaning.
stereotype that are widely used are defined in UML such as «include»
and «extend».
46
Section 4: More details on use case models
47
Section 4: More details on use case models
48
Section 4: More details on use case models
49
Section 4: More details on use case models
51
Section 4: More details on use case models
To extend or include?
We could show the log on use case as a component of every use case
that is associated with an actor.
Note that: there is no implication of ordering: time ordering is not shown in
use case diagrams.
52
Section 4: More details on use case models
53
Section 4: More details on use case models
One problem is that the focus may end up being top-down and function
oriented, resulting in an inflexible and difficult-to-maintain system.
Focusing on use cases may cause the developer to sacrifice the object
oriented nature of the system, thus losing any advantage that UML offers.
Another danger lies in mistaking design for requirements, where a design
decision is mistaken for a constraint.
Focusing on the requirements in a use case may cause the developer to
view the system too operationally, where a sequence of events is
assumed to be the only answer.
Developers need to distinguish between requirements and preferred
designs.
Use cases need to be used in a way that is understandable to the
customer but also useful to the developer.
54
Section 4: More details on use case models
Summary of Section
In this section, you have seen that use case models play a key role in the
development of a software system, especially when the user is placed at the
centre of a development process.
Use cases help you record the proposed requirements for a software system and
add detail to their relationships as follows.
The «extend» relationship between a new use case and an original use case
shows how the system should deal with conditional behaviour.
The «include» relationship shows how a subsidiary use case can provide some
common functionality to two or more use cases at a higher level of abstraction.
The «include» relationship between use cases shows how the system can
employ a pre-existing component.
Hence use cases provide a starting point for project and quality management.
55
Section 5: Getting users involved
Finding requirements involves identifying, recording and documenting the things that the
intended users do as part of their interaction with a system.
Usually a developer will produce textual descriptions of the potential scenarios and attach
them to the relevant use cases.
The domain of the developer’s expertise is software development, whereas the users
are experts in their own domain.
Even with the support of experts in the users’ domain, the most significant mistakes are
usually made during requirements analysis.
The cost of rectifying such errors increases the later they are detected in the development
process.
Thus identifying use cases and then testing them helps to detect or avoid the kinds of error
that might arise:
by missing a requirement
by not understanding a requirement
through ambiguity.
Agile developers stress a close involvement with the customer, accept that requirements
will be identified throughout development and that they will change.
56
Section 5: Getting users involved
57
Section 5: Getting users involved
58
Section 5: Getting users involved
Note that:
The main goal is to make sure that the prototype meets
the needs of its intended users.
Next, the developer needs to document what has been
achieved.
◦ This will provide the information on the final software system for
all those people involved in its development.
Finally, the people who should be involved in the
development of the prototype are the ‘real’ users.
59
Section 5: Getting users involved
60
Section 5: Getting users involved
The user interface is the link between what the users want and what the
developers produce in response
61
Section 5: Getting users involved
62
Section 5: Getting users involved
The activity diagram shows the interactions involved in enrolling a new member and the
activities carried out.
A nonmember of the library interacts with a librarian.
The non-member requests to be enrolled and provides information when requested by the
librarian.
The librarian then uses the system to record the enrolment information.
Therefore the librarian needs an interface with the software system for recording the
information.
This interface will be needed when a non-member request to enrol is dealt with by a librarian.
This transaction is complete when the library system:
Thus the user interface for the use case enrol new member must be available to the librarian
when dealing with the enrolment request.
63
Section 5: Getting users involved
The main benefit of recording user (or any other) interfaces in an activity diagram is
traceability.
To the users, the interface is the software system: an unacceptable interface can lead to
failure.
The user interface is the link between what the users want and what the developer
produces in response.
Also, the developer can identify the relative importance of each user interface for the
project plan, particularly when resources are needed for a prototype.
64
Section 5: Getting users involved
Summary of section
In this section, you have seen that activity modelling can help identify
when the user would need to use an interface to the proposed software
system.
You can use activity diagrams for any of the scenarios of a use case
where some interaction with an actor is expected.
Prototyping the user interface brings developers and users into close
contact with each other.
By working together it is possible to minimise any misunderstanding that
might lead to false expectations on either side.
65
Unit Summary
On completion of this unit you should be able to:
66