COMP3004 - Object-Oriented Software Engineering
Midterm from Fall 2009
Duration: 80 minutes
- These are the Q/A from the blue version of the midterm; there was also a white one but the answers were not given.
- As of 2010, there is a good chance that the course will be rewritten to accommodate something other than ROSE-RT. In that case, the questions listed below that pertain to ROSE-RT will not be relevant.
- I am not responsible for the mark any person gets on a future COMP3004 midterm.
- These Q/A are from a COMP3004 midterm given in a semester in 2009; I do not guarantee that any of them will be on a future version of the midterm.
- I do not guarantee the accuracy of these Q/A (but I did try my best).
1 (2 marks): With respect to how the containment relationship is implemented, distinguish Aggregation (white diamond) from Composition (black diamond) in ROSE-RT?
Aggregation is containment by pointer; composition is containment by data member.
2 (2 marks): What’s the purpose of a reference Message Sequence Chart?
A reference MSC allows an MSC to refer to another (the reference MSC). In turn, this allows the MSCs to be uncluttered.
3 (2 marks): Explain the difference between COMET and a scenario-driven approach to OO modelling.
In COMET, you first find classes/objects (from domain expertise) and then find scenarios (i.e. interactions between objects). In contract, in scenario-driven development, you refine use-cases into use case maps, and eventually MSCs, and then and only then identify objects and their classes.
4 (2 marks): What’s the purpose of stereotypes in UML modelling?
They allow the user to define/create labels with user-defined scenarios.
5 (2 marks): Why should use cases avoid referring to a specific interface for a system?
This should be avoided because the UI is typically subject to change frequently. If UCs refer to it, they will have to be changed as well.
6 (2 marks): What is the difference in lifetime of an object contained by aggregation vs. composition?
An object contained by aggregation has a life of its own outside the container because it is only referred to by a pointer in the container. An object contained by composition is created by the container and destroyed by the container.
7 (2 marks): With respect to testability, why do we build software models instead of just coding?
Models allow us to test code against something else (the models) as opposed to by itself.
8 (2 marks): What is the difference between a functional requirement and a non-functional requirement?
Functional: what the system does
Non-functional: in what fashion the system does a task
9 (2 marks): In a use case, what is the difference between a post-condition and a resulting event?
The post-condition is what must be true after the execution of the use case. The resulting event is the event that will necessarily occur once the UC terminates.
10 (2 marks): What’s the role of a base member initialization section of a constructor in C++? Where is it handled in ROSE-RT?
It allows the initialization of data members, and is handled in the C++ tab in the specification of data classes.
11 (2 marks): A single use case should be composed of what kind of scenarios?
One use case = one main scenario + several alternative/exception scenarios.
12 (3 marks): In a use case, you read “User presses floor button. This ‘floor request’ is added to the stack or requests kept by the system’s scheduler.” Identify two errors on this wording (what should be a good use case) and explain each one.
Error 1: “stack” refers to a specific data structure inside the system
Error 2: “scheduler” refers to a specific object inside the system
13 (2 marks): Why do we bother with use case maps after getting use cases? Why not just directly obtain message sequence charts?
UCMs provide a (conceptual) bridge between UCs and MSCs that refer to messages and instances/objects
UCMs provide an intermediate step between UCs (no objects/no messages) and MSCs
14 (1 mark): What’s the problem with limiting a use case to describing only one scenario?
You will have too many use cases.
15 (2 marks): Why do hierarchical states help with iterative modelling?
So you can have an abstract state early in development and refine it into substates later.
16 (2 marks): What’s the purpose of a coregion in message sequence charts?
It allows the user to capture one instance to send and receive a set of messages in any order.
17 (2 marks): Name one specific problem that often occurs when you have a large set of message sequence charts?
It is difficult to piece back in your head the overall control flow.
It is difficult to piece back in your head the actual sequence of messages across several diagrams.
18 (1 mark): What’s a “god object”?
An object that can set the state of another object (e.g. can access private data members of another object).
19 (1 mark): If you want a segment of code to be executed for all the transitions that leave the same state, then you would use the ____ section of that state’s specification.
20 (2 marks): When you have too few objects in a system, the complexity of the system is localized in the __. When you have too many objects in a system, the complexity of the system resides in the __.
21 (2 marks): Explain what is meant by the “principle of locality of change”.
Localize in one procedure/object what is most subject to change.
22 (1 mark): What is the purpose of a Trace monitor in ROSE-RT?
It allows monitoring of the message flow between one or more objects/capsules.
23 (2 marks): Does ROSE-RT support UML 1.4 or UML 2.0 sequence diagrams? What can the latter represent that the former essentially cannot?
ROSE-RT uses UML 1.4 sequence diagrams. A UML 2.0 sequence diagram can capture several scenarios/paths, whereas a UML 1.4 cannot.
24 (2 marks): Name two things that a capsule has in ROSE-RT and that a class does not?
ports; state machine/statechart
25 (2 marks): What is the difference between a protocol and a port?
A protocol defines in/out signals; a port of an instance of a protocol.
26 (2 marks): What is a relay port used for? What is its purpose?
A replay port relays in and out signals from/to subcomponents of an object/capsule.
27 (2 marks): What is meant by run-to-completion for statecharts? Be specific.
All code of all transitions traversed as the result of processing a single event must terminate before the next event is handled by a state machine.
28 (2 marks): What is the purpose of an end port p1 on a capsule c1?
Port p1 will have the signals it receive be handled by the statechart of c1.
29 (2 marks): What’s a conjugated port? When do we have to use one?
A conjugated port inverses the in/out signals of its protocol. It is required to connect a port of a capsule that uses the protocol to the port of another capsule that uses the same protocol but treats the INS as OUTs and the OUTs as INs.
30 (1 mark): Is several transitions entering a same state X all do the same things) at the end of their code, what can do to avoid this repetition of code across these transitions?
Use entry code section of the destination state to capture the shared code.
31 (2 marks): What is cohesion? What does it have to do with how to package responsibilities into objects?
Cohesion means you keep together things that belong together. Procedures should be put in the class that contains the data/instance variables/data members) they need to access directly.
32 (2 marks): What does a choice point do? If it were replaced by several distinct transitions, these transitions would necessarily have to use mutually exclusive ____ to avoid determinism.
33 (2 marks): When a signal contains data, the executing action code can reference the data using the ____ variable.
34 (1 mark): What is a probe in ROSE-RT?
It is something put on a port to inject signals.
35 (1 mark): What is the purpose of a structure monitor in ROSE-RT?
Its purpose is to put probes on ports.
36 (2 marks): What does the history mechanism do in a statechart? What does it have to do with global transitions?
The history mechanism takes a transition back to the last substate of a hierarchical state it reaches.
37 (1 mark): What is meant by decoupling two (or more) objects? Be specific!
Two objects are decoupled if changes in one do not entail changes in the other.
38 (1 mark): What does the use of private data members in a class have to do with decoupling?
Private data members can be modified without having this class affecting its users, thus they are decoupled from the users of that class.
39 (1 mark): How can an object send in a single signal several distinct data (e.g. suit and rank of a card)?
It must make a (data) class to represent all of what needs to be passed.
40 (1 mark): What’s the purpose of the numElementsFuncBody in ROSE-RT?
It says how the size of an object can be figured out so that the debugger can show it.