CS计算机代考程序代写 database KIT206 KIT206 Tutorial 4 – Sequence diagrams

KIT206 Tutorial 4 – Sequence diagrams

KIT206 Software Design & Development KIT506 Software Application Design & Implementation

1/3

Tutorial 4: Sequence diagrams
Purpose: To transform structured scenarios for the Human Resources Information System into
sequence diagrams, and to use these to determine operations that should be added to the classes
already modelled and to identify additional classes that may be required.

Outline
While class diagrams describe the different classes of objects present in a software system and the
ongoing relationships between them, they cannot describe the order of interactions between objects
for specific use cases. To do these we use sequence diagrams. Sequence diagrams are a form of
interaction diagram, and so describe the interactions between objects in the form of event/message
passing or method calling. In today’s exercises you’ll extend your skills with the StarUML CASE tool to
create sequence diagrams from one or more structured scenarios. You need the beginnings of an
object model to construct a sequence diagram, which is why last week you started developing class
diagrams for the HRIS. However, as part of the process you will discover the need for additional
operations within the classes you have already defined, and you may also discover roles in the system
that are not yet modelled by a class. Even in the real world it is common to alternate between static
(class) and dynamic (sequence) modelling while designing a system.

1 Preparation
Your starting point for this week is the system model you began last week. In order to keep the model
(as shown in StarUML’s Model Explorer) manageable, follow these instructions to add a placeholder
for all the sequence diagrams you will create.

Task: Reopen your HRIS model project in StarUML. In the Model Explorer add a Sequence Diagram to
your HRIS model. This will create three new nested elements in the model. Name the actual sequence
diagram ‘UC8 sequence diagram’, then rename the containing Interaction1 to
‘UC8_User_views_StaffList’ to match the first use case’s name, and rename Collaboration1 as
‘Sequence diagrams’. You can add additional sequence diagrams to this ‘Collaboration’ entry in the
model tree.

Next, right-click on the HRIS Model entry in the Model Explorer and select Add | Actor. You’ll see a
small stick figure icon added to your model tree. Rename this actor to ‘User’. You will use this to
represent the user triggering actions in the system in your sequence diagrams.

2 Creating a sequence diagram from a scenario
Task: Open the sequence diagram for Use Case 8 you created above and begin defining the sequence
of actions required for the first part of the use case’s interactions (remember, the user may not do
much but the system will do many things to retrieve and present the necessary information). Make
sure your structured scenario is open so you can refer to it to determine which actions need to take
place (and which kinds of objects may be responsible for carrying them out).

Objects in the diagram can be created by dragging the relevant class from the Model Explorer into the
sequence diagram (or, later, by assigning a new lifeline the same role that a particular object plays in
another sequence diagram). Since the user will instigate most system behaviour you’ll also need them
represented in the diagram: drag the User stick figure from the Model Explorer into the sequence
diagram and place it towards the left of the diagram.

KIT206 Software Design & Development KIT506 Software Application Design & Implementation

2/3

Method calls are referred to as messages. Once you have at least two objects (one of which may be
the user), select Message (in the Interactions (Basic) Toolbox) and drag from the calling object or user
to the receiver object. The message from the User to the first object in the sequence can be labelled
with a short English sentence, while other operations will be method names. See below for common
cases.

As you progress, ask your tutor to evaluate the sequence diagram against the structured scenario.

What are all these Roles?
For each object lifeline you add to a diagram, StarUML will create a Role in the Model Explorer.
This is how it keeps track of which class each object has and its intended role in the interaction. For
our purposes this level of indirection is unnecessarily complex, so here are some suggestions to keep
the number of roles manageable:

1. Rename each new role that’s created to be the same as its associated class or, if that’s not
known yet, a short name for its purpose/role in the current diagram.

2. Reuse roles for objects of the same type in different sequence diagrams: create a new
untyped Lifeline in the diagram and then select its role via the represent property in the
Property box. If you have more than one object of the same type in a sequence diagram then
there will (need to) be multiple roles for that class of object in your model.

You can set the class of an object in your sequence diagram either by double-clicking the lifeline’s
box and entering the type name after a colon (as in s : Staff), which will create another Role entry in
the model, or by selecting its associated role using the represent property in the Properties box.

Other issues and tips for using StarUML

I don’t know where to start!
Your sequence diagram will have at least the User icon, some object representing the part of the user
interface they will interact with (you can add details to that later), one entity object (such as a Staff
or Unit, etc.) and one object representing the interface to the database. For many of the use cases
you will have some object that is a collection of entity objects. If in doubt, add a Lifeline from the
Toolbox, give it a short but meaningful name, and make changes later.

I need something to receive the message, but no existing class seems suitable
Add a Lifeline from the Toolbox. When you have better idea what class this object should have, add
that class to the relevant package’s class diagram. Then return to the sequence diagram and set the
class of the object to match.

Will my objects be called Lifeline1, Lifeline2 and so on?
You can rename each object by double-clicking the box at the top of the lifeline or, if you really don’t
care about giving it an identity, you can delete its name via the Properties box.

What’s this interaction frame it adds to my new diagram?
You’ll notice that it adds an interaction frame to each otherwise empty new sequence diagram. You
can use this initial frame to hold the name of the use case, and you can even add more frames to label
sections of a sequence diagram representing different kinds of interaction (filtering, or searching, for
instance).

KIT206 Software Design & Development KIT506 Software Application Design & Implementation

3/3

What are these boxes on the life lines?
Whenever you drag a message from one object to another an activation box, which represents the
time that that operation/method is executing. It’s not to scale: boxes are made taller so that all the
calls that they trigger fit within their height in the diagram, not because they may take a long time to
execute. You will need to adjust the size of boxes to make them high enough.

The object has a class, but there’s no suitable method yet
Add a new message or double-click the one you wish to change and click the Create Operation
button. This will add the operation to that class’s definition without you needing to switch to the class
diagram where it is defined.

The object has a class, and I’ve previously added the operation I want to call
Add a new message or double-click the existing one and click the Select Operation button. Select
the appropriate method from the list shown.

I used the wrong kind of message. Do I have to delete it and draw the right one?
You can change the type of message by double-clicking the message and clicking the MessageSort
button to bring up a list of alternatives.

Outline
1 Preparation
2 Creating a sequence diagram from a scenario
What are all these Roles?
Other issues and tips for using StarUML
I don’t know where to start!
I need something to receive the message, but no existing class seems suitable
Will my objects be called Lifeline1, Lifeline2 and so on?
What’s this interaction frame it adds to my new diagram?
What are these boxes on the life lines?
The object has a class, but there’s no suitable method yet
The object has a class, and I’ve previously added the operation I want to call
I used the wrong kind of message. Do I have to delete it and draw the right one?