• Non ci sono risultati.

Exercises on basic UML behaviors

N/A
N/A
Protected

Academic year: 2021

Condividi "Exercises on basic UML behaviors"

Copied!
38
0
0

Testo completo

(1)

Exercises on basic UML behaviors

Paolo Ciancarini

(2)

Summary

•  This is a set of exercises on writing and understanding the UML notations

•  Some exercises have more than one correct answer

•  Most of them are taken from the net

(3)

Diagrams covered

•  State diagrams

•  Activity diagrams

•  Sequence diagrams

•  Communication diagrams

(4)

Think about it!

(5)

On state diagrams

This state diagram

a) Has a superstate “student”

b) Has a superstate

undergraduate”

c)  Has several final states d) Has several initial states

e) Describes two objects: student and undergraduate

(6)

On state diagrams

•  Describe at least three sequences of events which would get stuck this state diagram after 3 transitions

(7)

On state diagrams

The diagram represents a) A Document

b) A Printer

c)  A Word-processor

d) A User of a word-processor e) A Page being printed

f)  The diagram is invalid

(8)

On state diagrams

What is a guard condition in a state diagram?

a) An expression comparing the attributes of the modeled objects against the attributes of the associated object.

b) The condition of a person guarding the state diagram from unwitting destruction by the collaborating designers

c)  A boolean expression of attribute values which allows state transition only if condition is true

d) A boolean expression that allows the transition from the state of the current object into a state of another object in the system

e) A state activity that protects object attributes from accidental modification by unconditional actions of state transitions

(9)

On state diagrams

In a State Diagram, which of the following is true?

a)  Actions are associated with a transition and are considered to be processes that occur quickly and are not interruptible

b)  Actions are associated with transition and are considered to be processes that occur quickly and are interruptible

c)  Activities are associated with states and can take longer. An activity may be interrupted by some event

d)  Activities are associated with transition that occur quickly and are not interruptible

e)  Activities are associated with states and can take longer. An activity cannot be interrupted by any event

(10)

On state diagrams

In this diagram

a)  There are no loops b)  There are five states c)  Dispatching comes after

Checking

d)  Waiting is parallel to Delivered e)  There are no events

f)  There are simultaneous events

(11)

On state diagrams

•  Which condition statement?

Wait

Searching

Display results

Display no matches

entry/

Display search page

entry/

Display journal list

entry/

Display NoMatch msg

[empty list]

[else]

User enters search criteria/Query db

Db returns results

(12)

On state diagrams

Which of the following statements about state diagrams is correct?

a) All actions in a state diagram are attached to transitions

b) An event may cause an object to remain in the same state it was prior to the event

c)  Once an object leaves a state, it cannot return to that state

d) Two different transitions out of the same state may overlap (they can be triggered by the same event)

(13)

On state diagrams

•  What state(s) is the object in after the following sequence of events?

•  èa è b è c è b è g è a

(14)

On activity diagrams

•  Which of the following modeling elements are not found in an Activity Diagram?

a) associations b) swimlanes

c) initial node, final node d) fork and join nodes

(15)

On activity diagrams

•  What is the maximum number of concurrent threads that is possible in this activity diagram?

a)  1 b)  2 c)  3 d)  4 e)  5

(16)

On activity diagrams

In this diagram:

a)  Fill Order is executed before Receive Payment b)  Overnight Delivery is executed in parallel with

Regular Delivery

c)  Close Order is executed after Receive Payment

d)  Fill Order is executed in parallel with Send Invoice

e)  Send Invoice is possibly executed f)  Regular Delivery is always executed

(17)

On activity and sequence diagrams

•  Which sequence diagram is not consistent with the activity diagram?

(18)

On sequence diagrams

Which symbol represents a process activation?

a) 1 b) 2 c) 3

1  

2  

3  

(19)

On sequence diagrams

•  Which one of the following fragments of sequence diagram represents the action:

"Object A sends to object B several messages named msg”?

a) b) c) d)

(20)

On sequence diagrams

Which symbol represents a synchronous message?

a) 1 b) 2 c)  3

1   2  

3  

(21)

On sequence diagrams

What is this in the red oval?

a)  A message b)  A guard c)  An event

d)  An association

(22)

On sequence diagrams

Given the sequence diagram on right, which class diagram is consistent?

(23)

On sequence diagrams

Given the sequence diagram on right, which class diagram is consistent?

(24)

On sequence diagrams

•  What can you say about the control flow of each of the following systems?

–  Which is more centralized?

–  Which is more distributed?

24

(25)

On sequence diagrams

What is wrong with this sequence diagram?

25

(26)

On sequence diagrams

What is wrong with this sequence diagram?

26

(27)

On sequence diagrams

What are the names of missing classes XXX and YYY in the sequence diagram?

a)  XXX = DeliverySchedule, YYY = Supplier

b)  XXX = Supplier, YYY = DeliverySchedule c)  XXX = PreferredSupplier, YYY = DeliverySchedule d)  XXX = DeliverySchedule,

YYY = PreferredSupplier

(28)

On communication diagrams

This diagram contains

a) swimlanes and temporal marks b) objects and messages

c) classes and associations d) components and events

(29)

On communication diagrams

These two diagrams are equivalent or not?

(30)

On diagrams

Which among these are behavior diagrams?

a) Use case diagrams b) Class diagrams

c) State diagrams

d) Sequence diagrams

e) Communication diagrams f)  Package diagrams

g) Deployment diagrams

(31)

On diagrams

For understanding event control mechanisms, such as user interfaces and device controllers, which one of the following artifacts is the most useful?

a) Interaction Diagrams b) Activity Diagrams

c)  Package Diagrams d) State Diagrams

e) Class Diagrams

f)  Communication diagrams g) Deployment diagrams

(32)

On diagrams

What is the best diagram type to represent the sentence “all men are mortal”?

a)  Use case diagram b)  Class diagram

c)  Object diagram d)  Activity diagram

e)  Communication diagram

Mortal  

Man  

(33)

On diagrams

For the business modeling of a human organization or the workflow of a system, which one of the following artifacts is the most useful?

a) Interaction Diagrams b) Activity Diagrams

c)  Package Diagrams d) State Diagrams

e) Class Diagrams

f)  Collaboration diagrams

(34)

On diagrams

What are the nodes in this diagram?

a) Roles b) Actors

c) Use cases d) Artifacts e) Events

(35)

On diagrams

A car has a Starter, some Lights, an AirConditioning System, some Wheels. The driver operates first the Starter, then the Lights, then the AirConditioning System, and finally the Wheels.

Which pair of diagrams is most useful to model this situation?

a)  Use cases and scenarios

b)  Use cases and class diagrams c)  Class and sequence diagrams d)  Class and statechart diagrams e)  Class and object diagrams

(36)

Do-it-yourself exercises

Use case diagram describe how to play chess via an interface able to connect either different engines or a chess server via internet

Class diagram describe the pieces, chessboard and the game tree

Object diagram describe by object snapshots a chess position during a game Activity diagram describe a game workflow including two players playing via a

(telnet) chess server

Statechart describe a game workflow from the viewpoint of the chessboard Sequence diagram describe a multiagent system evaluating a position

Communication diagram describe a multiagent system evaluating a position

(37)

References

www.pearsonvue.com/omg/!

www.objectsbydesign.com/projects/umltest/bparanj-answers-1.html!

dn.codegear.com/article/31863!

parlezuml.com!

www.proprofs.com/quiz-school/story.php?title=quiz-uml-20!

(38)

Think about it!

Riferimenti

Documenti correlati

d) class Order { public Object getLineItems() ; public void addLineItem(OrderLine lineItem); !!.. On class diagrams. A benefit of using polymorphism is a

If, during this operation, an impulse is received from the photocell located at the sliding door, for security reasons the sliding door is opened, and the lift returns in the

Create a template class SmartPointer that holds a pointer Define constructor, copy constructor, and assignment operator. However, only one smart pointer object is

Create a template class SmartPointer that holds a pointer Define constructor, copy constructor, and assignment operator. However, only one smart pointer object is

Operations over Airport objects may not need to know details associated with cities, such as population When designing a class:. Apply the identity test to each attribute

Class model describes the static structure of objects and relationships in a system.. State model describes the dynamics aspects of objects and the nature of control in

Association describes set of potential links just like a class describes a set of potential objects.. Examples

Giuseppe Lipari (Scuola Superiore Sant’Anna) UML class diagrams March 13, 2011 1 / 31..