You are on page 1of 30

TM345 Essay Questions - Unit 6 to 11 Waleed Omar

TM354 ‫أسألة مجمعة من اختبارات‬


1. SAQ 5
What is the difference between generalisation and realisation?
Answer
Generalisation expresses a subtyping relationship between two classes. The subclass is a
specialised subtype of its superclass and inherits the attributes and operations defined by
the superclass. Realisation is not a subtyping relationship but instead expresses the fact that
a class provides an implementation for all the operations specified by an interface
2. (a) What does a final state signify in a state machine?
(b) In what ways does a final state differ from an initial state?
(c) What is the usefulness of using state chart diagram?
Answer
(a) Final states are used to show the point or points where the object in question has
finished processing. Its activity has been completed.
(b) There can be zero, one or more final states but at most one initial state. A final state can
have several incoming transitions and no outgoing transitions, but an initial state has no
incoming transitions and only one outgoing transition.
(c)
1. Identifying which messages affect which attributes
2. They help you understand the behaviour of an object over its lifetime.
3. They help you understand how an object or a system must respond to events.
4. They are a means of ensuring correctness.
5. They are a means of elaborating the potential operations within a class
3. (a) What is the main disadvantage of defensive programming?
(c) Are use case objects consistent with the twin aims of high cohesion and low coupling?
Answer
(a) the same constraints within each precondition may be checked repeatedly in different
operations.
(c)
Yes, because high cohesion asks us to ‘do one thing and do it well’. A CheckerIn class should
only support the one activity of checking in.
No, because having an extra class for each use case introduces more coupling through the
extra associations involved. The new classes limit the impact of change to a software system
4. (a) Why might two objects of the same class respond differently to the same message?
(b) What is the most common form of event that causes a transition between two states?
How is it shown in a state machine diagram?
(c) What is the difference between an event and an action?
(d) What is the main constraint on the kinds of action that may be shown in a state
diagram?
(e) What is an action sequence?
Answer
(a) An object’s behaviour will in general be affected by the values of its attributes, which are
part of the object’s state. If two objects have different values for the same attributes, they
are in different states, and therefore might respond differently to the same message.

Page 1
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
(b) The receipt of a message is the most common form of event that causes a transition
between states. An event is used to label the transition between the states. In a state
machine diagram, a transition is labelled with the name of the relevant message, which
includes any arguments for that message.
(c) An event is something done to the object, such as sending it a message. An action is
something that the object does, such as sending a message to itself or to another object. An
action is an object’s reaction to an event.
(d) Actions refer to things that the object ‘knows’ about. They can refer to attributes,
operations and links of the object. An action cannot refer to the state or attributes of
another object unless there is some way for these other attributes to be known in a short
time without requiring any state changes.

(e) An action sequence is an ordered series of individual actions that are associated with a
particular event. They are written as a list separated by semicolons, and are performed
sequentially in left-to-right order. Like actions, action sequences are atomic.
5. (a) Under what circumstances is one object, obj1 of class A, say, substitutable for another,
obj2 of class B, say?
(b) Once a class model that meets the contractual requirements of each use case has been
developed, what three sets of items in this class model should you examine to help you find
suitable postconditions when identifying the possible operations for a class?
(c) Figure shows a class model for the lending of books where there is a requirement to
record both past and current loans. Describe the contract to borrow a book in terms of
objects and links created. Your answer should differentiate between the pre- and the
postconditions.

Answer
(a) Class A must be a subclass of class B, and class A must respect all contracts agreed to by
class B.
(b) three sets of items when searching for the possible postconditions for an operation:
◦ instances of a class (its objects) that have been created or deleted
◦ instances of associations (links) that have been formed or broken
◦ attributes that have been modified. It is crucial of course that the postconditions reflect
the requirements and some practitioners would refer more directly to the requirements.
(c)
Preconditions:
there must be an instance of the class LibraryMember that corresponds to the real-world
member there must be an instance of the class Book that corresponds to the realworld book
that the member wants to borrow the instance of the class LibraryMember must be linked
to fewer than 3 instances of the class Loan in the role of currentLoans.
Page 2
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
Postconditions:
a new instance of the class Loan will have been created and the instance of the class
LibraryMember will have been linked to the new instance of Loan in the role of
currentLoans the instance of the class Book will have been linked to the same new instance
of the class Loan.
6. Give two reasons why it is useful to run a unit test before the relevant code increment has
been written?
Answer
(a) If the test unexpectedly already passes at this point, this demonstrates that it is not a
good test of the next increment.
(b) If it fails in an unexpected way, this demonstrates a faulty or incomplete understanding
of the test that needs to be addressed in order to have a good grip on the code and test.
7. What do you think is the relationship between system testing and acceptance testing?
Answer
In general, the same tests will be carried out during acceptance testing and system testing.
System testing is an in-house activity and a customer need never know how system testing
went – any bugs can be dealt with before the customer sees them.
Acceptance testing, on the other hand, is conducted with much more at stake – the
customer can accept or reject a system based on its performance at acceptance testing
8. Are there any situations in which system testing should be carried out by the implementers
of a system?
Answer
Probably the only situation where this is appropriate is when the project team is small. In
small teams, one person might play the part of requirements engineer, designer,
implementer, tester and maintenance engineer.
9. Service-oriented architecture offers a number of potential advatages. List them?
Answer
1. Agile and flexible response. SOA supports a flexible business model that can respond
quickly to changes in customers’ requirements.
2. Less duplication. If several parts of a business require the same function, it can be
packaged as a service and made available for reuse.
3. Integration of legacy applications. Legacy software can be wrapped as a service and
made to interoperate with other applications.
4. Use of third-party services. Systems can easily incorporate functions.
5. Language independence. Services written in different languages can interoperate
using standard protocols.
10. Discuss possible advantages of separating the user interface from the domain logic.
Answer
 The user interface is not affected by changes in the implementation of the business logic.
 The same domain logic can be used with different user interfaces.
 The business logic can be tested separately from the interface logic

Page 3
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
11. What are the various ingredients that make up a framework?
Answer
A framework consists of architecture, a small amount of software for the framework, a set
of components suitable for use within the framework and the documentation needed to
make use of the framework.
12. List the various forms of reuse and say briefly what is reused in each case.
Answer
 Architectural styles reuse expertise in large-scale architectural design – the types of
component used and the patterns of interaction between them.
 Frameworks reuse a particular architecture and a set of software components suitable
for use within it.
 Product lines reuse reference architectures, software components and expertise about
the variations needed to fulfil customer requirements.
13. List three main reasons for partitioning a software system as package diagram?
Answer
1. To manage size and complexity;
2. For information hiding;
3. For logical decomposition.
14. (a) In the analysis phase of system development, what were the assertions (preconditions,
postconditions and invariants) used for?
(b) Explain why pre- and postconditions express a contract between a client object and a
supplier object.
(c) What is meant by the term design by contract (DbC)?
Answer
(a) Assertions were used for placing constraints on the relationships between classes.
(b) The contract is expressed by:
 the precondition requiring something from the client object that is of benefit to the
supplier object
 The postcondition requiring something from the supplier object that is of benefit to
the client object.
(c) DbC is the process of developing software based on the notion of a contract between
objects.
15. 1. What does testing means?
2. Distinguish between white box testing and black box testing?
Answer
1- Testing is the process of exercising software to check that it does what it is supposed to.
2- In black box testing we design test cases by looking at the specification (that is,
requirements and high-level design) of the system to be tested;
In white box testing we design test cases by looking at the detail of the implementation
of the system to be tested.
16. An ideal black-box technique is partitioning. Mention it’s advantage and disadvantage?
Answer
 Advantage: it allows all possible user-perceived functions to be tested
 Disadvantage: for many (sub)systems the number of subdomains can be enormous,
and hence the effort involved in testing them all can be so large as to be prohibitive (costly).
Page 4
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
17. (a) How does the use of a pair of object diagrams help you prepare to build a sequence
diagram?
(b) Is the initial message on an interaction diagram always sent from an object representing
the user interface?
Answer
(a) The aim is to show how a given postcondition can be achieved in a sequence diagram. A
pair of object diagrams, showing the states before and after the operation in question,
identifies the changes in system state that take place in order to meet the postcondition.
(b) No – we are not constrained to showing interactions with the user interface. Message
sequences can originate from any object. The user interface is the origin for those messages
that relate to a use case scenario.
However, interaction diagrams can become very complex if we try to show all the possible
messages for a given configuration of objects. Following the principle of modularization, we
would split up a complex interaction into a number of smaller ones. In the new diagrams the
starting point need not be the user interface.
18. 1- Primary SQFs are measured in various ways. Mention the method to measure each of
the following primary SQFs
Correctness – Integrity – Maintainability – Usability.
2- List the two main tasks involved in verification of a system.
Answer
1-
1- Correctness measure: defects per thousand lines of code (defects per KLOC)

2- Maintainability measure: mean time to change (MTTC)


 The average of the times it takes to analyses a bug report, design modification,
implement the change, test it and distribute the change to all users.

3- Integrity is measured by considering the proportion of ‘attacks’ on a product as


opposed to bona fide uses.
4- Usability: Any system with a user interface and that will be used by people other
than the developers should be usability tested
2-
1. Ensuring that all system descriptions are self-consistent
2. Ensuring that all system descriptions are consistent and complete with respect to
those from which they were derived.
19. 1. In the contex of service oriented architecure; what is a sevice?
2. An SOA collaboration typically involces a find,bind and invoke cylce. Illustrate and list the
elements of this concept using diagram?
Answer
1- A service is an abstract description of some
unit of business functionality, usually
described in terms that are meaningful from
both a business and a technical
perspective.

2- The elements in this model are:


Page 5
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
1. The consumer.
2. The service.
3. The provider,
4. The registry (or locator)
20. a) Define WMPC metric
b) If the WMPC value of a class with twelve methods is over 100, how certain can you be
that this class is too complex?
Answer
a) WMPC (Weighted-methods-per-class) measures its complexity of behavior of a class. It is
defined as the sum of the cyclomatic complexities of each method of the class. In the
case of WMPC the cyclomatic complexity of each method is a weighting used to indicate
its complexity.
b) A complexity of greater than 12 × 10 = 120 is a fair indication that the behaviour of the
class is too complex
21. Which of the following tests are parts of validation and which are parts of verification?
Justify your answer
2.1 Unit testing
2.2 Integration testing
2.3 system testing
2.4 Acceptance testing
Answer
Unit testing can be used to demonstrate that a component satisfies
2.1 verification
a customer’s requirements – thus viewed as validation
Integration testing concentrate on whether parts of the system
2.2 verification perform according to their specifications, answering the verification
question (have we built the system correctly?)
System testing can be used to demonstrate that a system operates
2.3 validation
according to specification – viewed as verification
Acceptance testing focus on showing that the customer’s
2.4 validation requirements have been met, answering the validation question
(have we built the right system?)
22. List the Six principal steps of TDD (Test-driven development)
Answer
1. Decide on a code increment. 2. Decide on a test.
3. Write the test. 4. Run all tests, expecting the new test to fail
5. Write the code.
6. Run all the tests and succeed
23. Illustrate the Illustrate the LAMP stack with a diagram
Answer
A popular architecture for websites is the LAMP stack.
The acronym LAMP refers to the use of four open-source technologies:
 Linux
 Apache webserver
 MySQL database
 PHP (or Python or Perl)
Page 6
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
24. Java enterprise edition (EE) has made up of many technologies. List any six of them?
Answer
1. J2SE (Java 2 Platform, Standard Edition): The standard Java language, which Java EE is
built on top of.
2. EJB (Enterprise JavaBeans): A technology for reusable server-side business components,
called enterprise beans.
3. Servlets, JSF (JavaServer Faces) and JSP (JavaServer Pages): Technologies for
constructing web pages and serving them to clients on demand.
4. JPA (Java Persistence API): A technology for accessing relational databases.
5. JMS (Java Message Service). A technology enabling software components to
communicate asynchronously with low coupling.
6. JAX-WS (Java API for XML Web Services) and JAX-RS (Java API for RESTful Web
Services: Technologies for providing services that can be accessed over the internet.
7. JavaMail: A technology for sending email messages

25. 1- List any two software quality factors affected by product revision requirements?
2- List any two software quality factors affected by product transition requirements?
3- List any two software quality factors affected by product product operation
requirements?
Answer
1 maintainability: the effort required to deal with expected changes and to understand,
locate and fix errors in a system
flexibility: the effort required to modify an operational system
Testability: the effort required to test a system to ensure that it performs its
intended function.
2 Portability: the effort required to transfer the system from one hardware platform
and/or software environment to another.
Reusability: the extent to which a system (or system component) can be reused in
other applications.
Interoperability: the effort required to couple one system to another.
3 correctness: how well a system fulfills the customer’s overall objectives
reliability: the likelihood with which a system can be expected to perform its
intended function
efficiency: the level of computing resources (including time) required by a system
to perform its function
26. In a computer graphical user interface, how might you represent the relationship between a
full window and an iconized window from the classes FullWindow and Icon respectively?
Answer
You could introduce a new, abstract class named Window and let the other classes inherit
from it as follows:
 abstract class Window with operation display
 subclass Icon with additional operation maximize
 subclass FullWindow with additional operations iconise and scroll

Page 7
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
27. (a) Do packages contain only classes?
(b) Which modelling principle would lead you to form packages?
(c) Explain how it is possible to have two separate elements that share the same name.
(d) The stereotypes «import» and «access» allow you to ‘see’ through the ‘wall’ around a
package. Which one can give rise to a naming problem? Which one provides the simpler
traceability?
(e) Suppose you use «access» to ‘see’ into a package. Can you see everything inside that
package? Briefly explain your answer.
Answer
(a) No – they can contain any model element from UML. Among other things, you can
include classes, use cases, associations and even other packages.
(b) You should use a package to raise the abstraction level, suppressing any detail in a
particular diagram that is not necessary to understand what the model is showing.
(c) If you place the two elements in separate packages, they can share the same name.
Because each model element is identified by its name and the name of the smallest package
that contains it.

(d) The «import» stereotype can give rise to a naming problem, because an «import» adds
the names of the elements in the target package to the source package. If an imported
name clashes with an existing name, you have to qualify the imported elements with their
package name in order to distinguish them. The «access» stereotype allows simpler
traceability, because other packages must use the full name of an accessed element, such as
PackageName:: ElementName.
(e) There is no guarantee that you can ‘see’ all the elements of the package. An element of
the accessed package can be marked as private, making it invisible to other packages that
import this package and indicated with a ‘–’ character. Alternatively, it can be marked as
protected, making it invisible to importers of the package but visible to child packages, and
indicated with a ‘#’ character.
28. List the advantages and disadvantages of building software by plugging together off-the-
shelf components.
Answer

Advantages
 Reusing a standard component should be cheaper than developing software from
scratch.
 Using off-the-shelf components will allow applications to be developed more quickly.
 Standard components will have been used in many other projects, so their behaviour will
be well understood and any bugs are likely to be known.
 Components are pluggable, so it is often possible to replace one component with
another providing it has the same interface and behaves in the same way.
Disadvantages
 Using standard components may restrict what we can do since we have to work with the
capability of the components.
 If the interfaces of components are incompatible, adapters will have to be written.
 Creating a system by plugging together off-the-shelf components may not be simple.
Page 8
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
29. What is the difference between provided interfaces and required interfaces of a
component?
Answer
Provided interfaces provide access to the services of the component. Required interfaces
are the interfaces of the components required (needed) by a component in order for it to
supply its services.
30. List as many ways as you can think of to reduce coupling. You will probably have come up
with a number of them already when answering
Answer
 Use components that hide their implementation behind interfaces.
 Use services that hide their implementation behind interfaces.
 Use a layered architecture.
 Use packages to group closely related elements.
 Separate model from presentation.
 Hide legacy software behind wrappers.
 Delegate object creation to factories.
31. How are the model-view-controller(MVC) and observer software patterns
related?
Answer
The Observer pattern plays an essential part in the MVC pattern. When user inputs to
the controller lead to changes in the state of the model the changes are reflected in
the view, but we didn’t say how this happens. The explanation is that the view is an
observer that is registered with the model. Whenever the model changes the view is
notified and can then update itself.
32. Think of some reasons why reuse is desirable.
Answer
We thought of several reasons. You may have come up with others. It avoids duplication of
effort and reinventing already existing solutions, which saves resources. It promotes
reliability because developers can use tried and trusted solutions. It speeds up development
because developers can take existing solutions without starting from the beginning every
time. It is a mechanism for spreading good practice among the software development
community and familiarizing practitioners with tried and tested solutions

Page 9
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
M363 ‫أسالة مجمعة من‬
33. What is an interaction diagram used for?
Answer
It is used to show how messages pass between objects within the software system to carry
out some task.
34. What is a state machine?
Answer
It is a dynamic model that records the changes in configuration of a particular object.
35. Compare between the sequence and collaboration diagrams. Or mention two types of
interaction diagram and distinguish between them?
Answer
A sequence diagram:
1. Shows the flow of messages from object to object as time passes by.
2. Makes the time relationship clear.
3. Shows only the objects involved in a particular sequence and it may not be easy to see
overall patterns of message flow.
A Collaboration diagram:
 Shows the objects and their links (the structure) and the flow of messages as they pass
along the links.
 Makes the interconnections between objects clear.
 Needs a numbering system since the actual sequence of messages can be difficult to see.
36. What is the difference between an activity diagram and a sequence diagram in terms of the
flow that each one represents?
Answer
 An activity diagram shows the flow of control from activity to activity, whereas a
sequence diagram shows the flow of control from object to object.
 An activity diagram shows the dynamic behavior associated with a use case whereas a
sequence diagram shows part of the dynamic behavior of some typical objects.
37. What does the phrase to delegate mean in the context of object-oriented design?
Answer
One object is said to delegate behavior to another when instead of implementing some
behavior, it sends a message to another object which implements that behavior.
38. According to the Law of Demeter, an object should only send messages to a certain set of
objects. List these objects.
Answer
1. The object itself.
2. Any object communicated as a parameter of the current method.
3. Any new object that the object has created in the current method.
4. Any object to which the object has direct links - its neighbors.
39. What kind of event are the following?
1. a message
2. entry and exit events
Answer
1) A message is the commonest case of a call event.
2) Entry and exit events are time events.

Page 10
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
40. What is the relationship between an activity diagram and any supporting sequence diagrams
that are used to elaborate the implementation of an operation?
Answer
An activity diagram describes how a particular rule or computation can be performed. It
shows all the paths that are allowed and also any concurrency. Sequence diagrams are
used to show how a particular set of conditions conform to the computation described in the
activity diagram.

A sequence diagram can be used to illustrate a single path of execution for a given scenario,
and you would need a set of sequence diagrams to illustrate all the possible scenarios that is
shown in only one activity diagram.
41. What is an assertion? What is an assertion in DBC?
Answer
An assertion is making a claim that something is either true or false. In DbC, an assertion is
the collective name given to pre-conditions, post-conditions and invariants. During
execution an assertion which evaluates to true will have no effect; an assertion that
evaluates to false indicates an error in the system.
42. What is an assertion mechanism? What is the main use of it?
Answer
An assertion mechanism is a programming construct which, at run-time, allows an assertion
to be executed. The main use of an assertion mechanism is when an assertion evaluates to
false, in which case the assertion handling mechanism will, in some way, alert the user of the
system to that fact.
43. What are the restrictions need to be placed on the assertion in subclasses in order to meet
the requirements of DbC?
Answer
a. The pre-condition of the subclass is the same or weaker (this allows more input);
b. The post-condition of the subclass is the same or stronger (provides a ‘better’service)
c. The invariant of the subclass is the same or stronger.
44. What is the difference between a component model and a deployment model?
At what stage of the development process would you use each of them?
Answer
The component model shows the relationships between parts of source code, libraries,
executables, and any other artifact that has a compile-time dependency.

The component model is part of the development view. Once all the code has been
compiled and exists as executable units, the location and relationship between executable
units is shown by the deployment model, which forms part of both the physical view and
process view.

You would consider the component model when looking at linking and compiling source
code, while the deployment model would be important when installing executing processes
on individual processors.
45. What is the relationship between a component and a class? or Explain whether Java classes
are an ideal components or not.
Page 11
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
Answer
An ideal component is well-specified, replaceable, and has provided and required interfaces
for communication with other components. It should have the qualities of information hiding
and encapsulation. Java classes offer most of these features. They provide encapsulation and
information hiding, (using private and public keywords).

A Java class has an explicit provided interface.


However Java classes fail of being ideal components since their provided interfaces cannot
be subdivided, and their required interfaces are not explicitly specified.
46. Give one difference between Java Beans and Enterprise Java Beans.
Answer
1-EJBs have more facilities to aid the development of very large distributed systems.
2-EJBs are seen as medium-sized (‘medium-grained’) components; for small things like
addresses, JavaBeans or simple Java classes would be more appropriate
3-EJBs are server-side components, whereas JavaBeans are primarily client-side.
47. What
- do we mean by software architecture?
Answer
Software architecture is a high-level abstract description of the structure of a software
system — its major parts and how they are interrelated.
48. What are patterns? And what is their beneficial?
Answer
Patterns are records of good solutions from experienced software engineers. They could be
used to solve frequently recurring problems and to provide a way of overcoming those
problems
49. What is the relationship between a software pattern and a framework?
Answer
Both patterns and frameworks are concerned with reuse. A pattern describes a way of making
experience available for reuse; it documents a well- known software problem and a good
solution to it.
A framework recognizes a reusable similarity at a higher level, in which two systems have
architectural features in common. It is reusable architecture. It will usually be accompanied by
code that represents components which can be fitted into the framework.
50. Distinguish between consistency and completeness.
Answer
Two system descriptions are consistent means that, where they describe the same part of
the system, they do not contradict each other. Consistency with a customer requirement
means that the requirement is met. Completeness means that everything that should have
been ‘said’ in system description has been ‘said’
51. What is the difference between verification and validation?
Answer
 Verification is the process of checking that each system description is self-consistent, and
that different system descriptions are consistent and complete with respect to each
other. Are we building the product right?
 Validation is the process of checking that each system description is consistent with the
customer's requirements. Or shortly: Are we building the right product?
Page 12
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
52. When does an architectural model appear in the development of object- oriented systems?
Answer
The architectural model appears at the end of analysis, as the specification model.
53. Which of unit, integration, system and acceptance testing are parts of validation and which
are parts of verification?
Answer
Unit and integration testing: how parts of the system perform singly or together, answering
the verification question (have we built the system right?). System and, therefore,
acceptance testing: showing that the customer’s requirements have indeed been met,
answering the validation question (have we built the right system?).
54. What does testing a software mean? What is the difference between black- box and white-
box testing?
Answer
Testing is the process of executing a software system, or part of a software system, in order
to check that it meets its requirements. In black-box testing we choose test cases by looking
at the specification (i.e. requirements and high-level design) of the system to be tested.
In white-box testing we choose test cases by looking at the detail of the implementation of
the system to be tested.
55. What basic problem does configuration management aim to solve?
Answer :
The problem of incompatible versions failing to work together.
56. Describe 2 different methods for measuring the complexity of a given system.
Answer
1-LOC (the number of lines the code consists of)
2-Cyclomatic complexity metric (counting number of independent paths in code)
57. Suppose that op1 overrides op2. What are the implications in terms of input and output if:
• op1 has a weaker pre-condition than op2;
• op1 has a stronger post-condition than op2.
Answer
Op1 convenient for the client since the input easier than op2 and the output or service
stronger than op2.
58. Distinguish between Fork and Cascade models?
Answer
Fork object send message to another object that are not linked with it directly .
Cascade object send message to another object via object which is linked between them.
59. Assume that the class TempAccount is a subclass of BankAccount which redefines the pre-
condition of the method credit to be:
anAmount > 10;
What are the implications of this change with respect to DbC? Explain.
Answer
The pre-condition in the method credit in class TempAccount is strength than the pre-
condition of the method credit in class BankAccount so this Violate the concept of subtype.
60. Do we prefer weakening the pre-conditions? Why or Why not?
Answer
Yes , we do. By weakening the preconditions it becomes easier for the client to satisfy them
because there are ‘fewer’ conditions to be satisfied.
Page 13
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
61. List four advantages of using layered architecture?
Answer
 separation of concerns - lowered coupling
 reuse - flexibility
62. Functional view is one of architectural views. What does functional view describe?
Answer
 the system’s main functional elements,
 their responsibilities,
 interfaces
 and primary interactions.
63. What particular benefits can state machines bring to object-oriented design?
Answer
The benefits of using state machines are that they
1. model the behaviour of an object across more than one use case
2. model the lifecycle of an object
3. show how an object must respond to events
4. might be used to help prove program correctness
64. a. What does weakening a pre-condition mean in terms of the provision of a service?
b. What does strengthening a post-condition mean?
c. Why a class model is not sufficient to describe a system?
d. What you should indentify in Dbc contract?
Answer
a- To weaken a pre-condition means generalizing the situation in which a service can be
provided so that we have ‘fewer’ conditions to satisfy.
b- To strengthen a post-condition means making ‘better’ the service that is requested, in
terms of time, precision, or some other measurable item.
c- It is a static model that describes the elements of a system (classes) and their
relationships (associations), and It does not describe behavior over time. You need a
dynamic model to do so.
d- The operations appropriate for each class are identified and what each operation expects
and should achieve should be specified by pre- and postconditions.
65. What does an assertion handling mechanism mean? And what it is main use?
Answer
An assertion handling mechanism (or assertion mechanism for short) is a programming
construct, which, at run-time, allows an assertion to be executed.
The main use of assertion mechanism is when an assertion evaluates to false, in which case
the assertion handling mechanism will, in some way, alert the user of the system to that fact.
66. Describe how Model-View-Controller (MVC) pattern work?
Answer
o The model, an object with some information about the domain. The model contains data
and behaviour and is not a visual object. In a layered architecture, the model resides in the
business layer.
o The view is the graphical manifestation of the model in the user interface: it is what the user
perceives of the model. Views reside in the presentation layer of a layered application.
o Controllers are also presentation-layer objects. the user inputs to the controller translate
into changes to the model’s state, which in turn are reflected in the view.
Page 14
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
67. In terms of observer pattern, what are the responsibilities of subject and observer?
Answer
Subject responsibilities:
 The subject keeps a registry of observers,
 Notifies any change to all the observers in the registry.
Observers responsibilities:
 The responsibility of the observers to register (or de-register) themselves from the
registry.
 It is also the responsibility of the observers to take an appropriate action upon
notification.
68. What is the difference between generalization and realization?
Answer
 Generalisation expresses a subtyping relationship between two classes: the subclass is a
specialised subtype of its superclass, and instances of the subclass can appear anywhere
that instances of the superclass can; the subclass inherits attributes and operations of the
superclass.
 Realisation is not a subtyping relationship, but instead asserts that a class realises a
protocol specified by an interface. The realising class provides an implementation for all
the operations that are declared in the interface.
69. List two main differences between communication diagrams and sequence diagrams?
Answer
 A communication diagram shows in one place all the links of interest between objects,
whereas a sequence diagram does not.
 The time-ordering of messages is clear in a sequence diagram. Some form of numbering is
needed in a communication diagram to show the time-ordering of messages, and the
numbering can become very complicated. If we did not have a sequence diagram for
comparison.
70. List the four distinct types of testing that occur during a software development project. Define
each?
Answer
o Usability testing, in which the functionality and user interface are tested to ensure that they
are fit for the intended users.
o Developmental testing, which checks that developmental activities have been carried out
correctly, and ideally it is performed by development staff other than the authors of the code
and checked by quality assurance (QA) staff;
o Requirements-based testing, which checks that a system meets the customer’s
requirements, and it is carried out by QA staff in conjunction with the customer;
o Regression testing, which occurs during developmental testing and system maintenance,
and checks that fixing one bug has not introduced others.
71. List the three general types of requirements?
Answer
1. Product operation requirements,
2. Product revision requirements,
3. Product transition requirements.
Page 15
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
72. The
-- files stored on a hard disc are usually organized into folders. Does a folder act as a
namespace? Explain your answer?
Answer
Yes a folder on a hard disk is a namespace. Within a folder, names of files and folders must be
unique, but the same name can occur in different folders without causing a problem.

Can packages interact with one another? Explain your answer?


Answer
No, packages cannot interact with one another.
A package: cannot be instantiated, does not have an interface and does not respond to
messages.
73. Explain what ‘guards’ are in UML and how they are used in:
a. Activity diagram;
b. Sequence diagram;
c. Communication diagram;
d. Statechart diagram.
Answer
A guard is a boolean condition that may be applied to determine the occurrence of
1. a transition (in statechart and activity diagrams) or
2. a conditional message send (in sequence diagrams and communication diagrams).
In each case the action will take place only if the condition evaluates to true.
3. In statechart and activity diagrams guards are used to control which one of two or more
mutually exclusive transitions will be taken from a decision node.
74. Figure below shows a Google search, in terms of MVC pattern which part in this figure
represents the model, which one represent the view, and which one represents the
controller?

Answer
The model is the data – the search indexes and rankings that Google hold on its servers.
The controller is the box for the search term and the Search button.
The view is the list of hits.
75. List the advantages of using MVC pattern?
Answer
Separation of concerns
Easier testing
Flexibility
76. List the three strategies that are used to choose which object in software system should
receive the message form user interface.
Answer
 One central class
 Actor class
 Use case classes
Page 16
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
77. What software quality factors the complexity could affect? Explain your answer?
Answer
Complexity affects the following software quality factors:
1. Reliability: complex code is more likely to contain bugs.
2. Maintainability: complex code is more difficult to modify.
3. Flexibility, complex code is more specific to particular circumstances.
4. Testability: it is harder to design test cases for complex code.
78. What aspects of a software system might the LOC metric be a useful indicator of?
Answer
LOC may be an indicator of:
1. The number of errors.
2. Maintenance effort.
3. The number of person-years needed for system development.
4. Measuring complexity of specific code.
79. List four of the complexity metrics used for object-oriented systems?
Answer
Depth of inheritance tree (DIT), Coupling between objects (CBO), Number of children (NOC),
Response for a class (RFAC), Lack of cohesion in methods (LCOM), Weighted methods per class
(WMPC)
80. 1- What does assertion mean in Java?
2- In terms of design by contract, what does it mean?
Answer
1- In Java, an assertion is a statement of what must be true at a particular point in the
execution of a method.
2-
a. if a precondition assertion is false, the client code has not met its responsibilities (to satisfy
the precondition);
b. if a postcondition assertion is false, the supplier code has not met its responsibilities (to
deliver the postcondition, or do what is expected).
81. What is the cyclometic-complexity metric?
Answer
It’s a technique measures the complexity of method by counting number of independent
paths in method.
82. What are the software quality factors that are affected by product operation requirements?
Explain each factor?
Answer
 Correctness, which determines how well the software does what the customer wants;
 Reliability, which determines how well the software does what it is supposed to do;
 Efficiency, which determines the level of computing resources (including time) required by
a system to perform its function, that is how well it runs on the customer’s hardware;
 Integrity, which determines how well the data is secured;
 Usability, which determines how easy the system is to use.
83. Classify each of the following design patterns if it is:

MVC, application controller, observer, singleton, factory.


Page 17
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
a. ………….. pattern is used to ensure that a class has only one instance, and to provide a
global point of access to it. (singleton)
b. …………. pattern is used to split user interface interaction into three distinct roles. (MVC)
c. ………….. pattern is used to design a one-to-many dependency between objects so that
when some internal state change occurs in one object, all its dependants are notified
automatically. (observer)
d. …………. Pattern is used to define a specialised object for the creation and initialisation of
other objects. (Factory)
e. ………….. pattern is used to have a centralised point for handling screen navigation and the
flow of an application. (application controller)
84. An example of a natural language description of the contract of a borrow operation from a
library is as follows:
A library member can borrow books as long as the book is available, and the total number
of borrowed books does not exceed a maximum limit of five book/member.
1. Obtain pre and post-condition of borrow() operation
2. Represent pre-condition as assertions using Java language.
3. public void borrow(int n, String name, String bookID)
{
// n: number of books
// name: name of customer
}
Solution:
1. Pre-conditions: a customer must be a member, number of borrowed book does not exceed
5 books, book is available.
Post-condition: the number of borrowed books of member will have been increased by 1 per
each book.
2.
public void borrow(int n, String name, String bookID) {
assert name is a member && (n > 0 && n < 5),&& bookID is available
// the body of the method
}
85. 1- Is a state chart diagram considered as static or dynamic modeling? Explain your
Answer.
Dynamic modelling [1] because it shows states, transitions and events that captures life
history of an object (it models changes within an object as a result of receiving a message)
2. In a state chart diagram a transition have 5 parts. Mention these parts and give examples to
it from figure 1.

Solution:
Source state: unoccupied
Target state: occupied
Event: accept(aGuest)
Action: setOccupant
Guard: available room > 1
Page 18
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
86. 1. For a particular system, system testing should consist of 7 parts. List them.
Answer
 user-command testing (or operator testing
 interface and protocol testing
 start-up and initialisation testing
 restart testing
 performance testing
 stress testing
 security testing
2. What does the cyclometic-complexity metric measure?
Answer
It’s a technique measures the complexity of method by counting number of independent
paths in method.
87. 1. What does integrity determine? How is it measured?
Answer
Integrity, determines the extent to which access to data by unauthorized persons can be
controlled, that is how well the data is secured.
Integrity is measured by considering the proportion of ‘attacks’ on a product as opposed
to bona fide uses.
2. What is the main weakness in the diagram of sequence diagram?
Weakness of sequence diagram is:
Answer
It may not be easy to see overall patterns of message flow, as each diagram shows only the
objects involved in a particular sequence.

Page 19
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
Unit 6 - SAQ
88. SAQ 2
To what extent can DbC help with traceability, and hence be used to improve the quality of a
software system?
Answer
DbC allows the development of software system to be traced from requirements through to code.
89. SAQ 3
What is the relationship between the client’s and supplier’s obligations and benefits?
Answer
A client’s obligations to constrain inputs provide benefits to a supplier in that fewer input
cases need to be considered. A supplier’s obligations to produce outputs satisfying certain
constraints mean that a client can expect to receive a clearly defined service.
90. SAQ 4
(a) What does weakening a precondition means in terms of the provision of a service?
(b) Similarly, what does strengthening a postcondition mean?
Answer
(a) Weakening a precondition means generalizing the situation in which a service can be
provided. In general, this means that it is easier for the client to satisfy the precondition
because there are ‘fewer’ conditions to be satisfied.
(b) Strengthening a postcondition means making the service that is
requested ‘better’ in terms of time, precision or some other measurable item. The precise
notion of ‘better’ is not fixed, but must be considered in terms of the contract of which the
postcondition is part. It can, however, make the postcondition more difficult for the supplier
to satisfy because there are ‘more’ conditions to be satisfied
91. SAQ 7
(a) In an interaction diagram, which class must provide the operation indicated by a message
passed from one object to another?
(b) What does a lifeline represent?
(c) What does the box at the top of a lifeline include?
(d) What sort of arrowhead is used on an arrow depicting synchronous message sending?
(e) What is a procedural interaction? With what might it be contrasted?
(f) In a sequence diagram, what does the widening of a lifeline into a tall, thin rectangle
mean?
Answer
(a) The class of the receiver object must provide the appropriate operation.
(b) A lifeline represents the portion of the life of an object covered by the sequence diagram.
(c) It includes an instance name, optionally followed by a colon and a class name, or, for a
generic object, just a colon and a class name. For example, objectname, objectName :
ClassName and : Classname are all allowed.
(d) A solid black arrowhead, which indicates that the interaction is procedural. An arrowhead
with a dashed shaft is used to signify the method’s return, although it is often omitted for
clarity.
(e) It is an interaction in which the sender of a message is blocked until the receiver of the
message has finished processing. This is exactly the same as what is sometimes called
subroutine semantics. It is the usual policy when a single thread of control is allowed.
Page 20
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
(f) This shows that the object is active. An object is said to be active if it is either performing
an operation or awaiting completion of an operation that it has requested another object to
perform.
92. SAQ 8
(a) What does to delegate mean in the context of object-oriented design?
(b) Would you describe a sequence diagram as a programming notation?
Answer
(a) One object is said to delegate behaviour to another when, instead of implementing some
behaviour, it sends a message to another object that implements that behaviour. We
considered the possibility that instead of the Hotel doing all the work of finding a free room
and housing jill in it, the Hotel might delegate the work to a Room by passing it the message
attemptToAccommodate(jill).
(b) Not really, because all it shows is the inter-object message traffic. It does not represent the
algorithms needed by senders in order to decide when and to which objects messages should
be sent, or those needed by receivers in order to act on the messages.

When you have finished drawing sequence diagrams you know the interfaces of the various
classes but not how those interfaces will be implemented
93. SAQ 9
(a) How is the sequencing of messages represented in a communication diagram?
(b) Sequence diagrams and communication diagrams show almost equivalent information.
What are their respective strengths and weaknesses?
Answer
(a) Every message has a multi-stage number. The numbers specify the sequencing, replacing
vertical position in a sequence diagram.
(b) Sequence diagrams make the relative order of messages extremely easy to see by
presenting time vertically. Communication diagrams are an extension of object diagrams, so
there is less new notation. They make it easy to see the links and to show role names, at the
cost of making the relative ordering of messages less immediately clear.
94. SAQ 10
(a) What is the difference in emphasis between sequence diagrams and communication
diagrams?
(b) How is time represented in a communication diagram?
(c) What obligation is placed on an object that is sent a message?

Answer
(a) Sequence diagrams emphasise the flow of messages from object to object over time.
Communication diagrams emphasise the message traffic across the links in a particular
configuration of objects.
(b) Time is represented by the sequential numbering of messages.
(c) The class of the receiving object is committed to implement an operation with a particular
name and parameter signature.

Page 21
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
95. SAQ 11
How does an assignment statement help construct a prototypical sequence diagram?
Answer
In a programming language, an assignment statement allows you to store the result of one
message in a variable and then send messages to whatever object is currently referenced by
that variable. You can use the same mechanism in UML, although the name used to store the
message result is not the same as a programming variable. The name can then be used as a
parameter to other messages. In a bank, for example, you might want to credit an account
with an amount of money. You can use a name such as ac to store a reference to an Account
object (at a particular branch) and then send a message, such as credit(amount), to that
object.
96. SAQ 13
(a) How does a sequence diagram drawn for a use case scenario differ from one drawn to
show how an internal operation, such as findAFreeRoom in Figure 14, is carried out?
(b) Would you expect to use sequence diagrams in a conceptual model?
Answer
(a) A sequence diagram of a use case scenario will always have the very first message
originating from an object which has been stimulated, directly or indirectly, by an actor
(usually a user interface object). An internal operation will be invoked by a message that has
been identified in the use case scenario. You can show how the recipient of that message
achieves the required behaviour, for example how a free room is found. In all other respects
they are the same.
(b) Sequence diagrams are about message passing between software objects and conceptual
models are about things in the world, where the language of message passing makes no
sense.
97. SAQ 14
What are the advantages of recognizing when an association is unidirectional?
Answer
Specifying an association in just one direction simplifies the implementation of the classes at
each end and avoids the need to worry that both ends of the link are consistent when dealing
with instances of those classes. But be aware that the overall flexibility is reduced in
comparison with bidirectional associations
98. SAQ 15
Suppose that, in a Java implementation, a Company class represents the employment
association with the Person class as a Vector of Person objects. What would be the
disadvantage of providing a method Company::getAllEmployees that returned the Vector?

Answer
If Company::getAllEmployees is defined as returning an instance of the class Vector, changing
the internal representation creates either a maintenance problem or a data-type conversion
problem. Suppose the internal representation is changed to be an array. You then have to
decide whether getAllEmployees should be changed to return the array (affecting all existing
clients of the class) or a new Vector should be constructed from the array.

Page 22
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
99. SAQ 16
According to the Law of Demeter, an object should send messages only to a certain set of
objects including the object itself. List the other objects.
Answer
◦ any objects communicated as parameters of the current method
◦ any new objects that the object has created in the current method
◦ any objects to which the object has direct links – its neighbours
◦ itself.
Unit 7
100. SAQ 1
Why must the conditions on a message send be mutually exclusive in a sequential system?
Answer
If conditions were not mutually exclusive, more than one condition might be true. This would
mean that multiple messages would be sent at once, resulting in multiple receiving objects
being active at the same time – leading to the possibility of non-deterministic behaviour.
101. SAQ3
Give an example of an architectural decision that would provide a general solution to the
problem of unexpected messages.
Answer
At an architectural level we might introduce a single object of a class Error, which is globally
accessible to objects in the software system. Such an object would be responsible for
reporting errors due to unexpected messages, for example.
102. SAQ 6
What is a guard and how does it protect a transition?
Answer
A guard is a Boolean condition that is applied to a transition – the guard must be either true or
false. A guarded transition can only take place when the specified guard is true.
103. SAQ 7
(a) What is an entry event, and how does it contribute to the maintenance of a state diagram?
(b) What is the benefit of using an internal event as opposed to a selftransition?
Answer
(a) An entry event can be used where there are multiple transitions, with the same actions,
leading to a particular state in a given diagram. An entry event occurs every time an object
enters the state that it annotates. Entry events reduce the risk of introducing errors, because
the action sequence is written once (associated with the entry event of the state) rather than
many times (on each of the transitions leading to that state).
(b) When there are entry and exit events that might interfere with a self-transition, an internal
event is useful because the entry and exit events are not triggered.
104. SAQ 8
(a) Identify three problems associated with complex state diagrams that might arise when
designing classes.
(b) Suppose the class Copy included the attributes returnDate, libraryNumber and
classification. Which of these attributes are significant for a state machine for the class Copy
that has two states called on shelf and on loan? Explain your choice.
Page 23
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
(c) Suppose you implemented your design for a class without using a state diagram. Are there
any subsequent activities where a state machine might help you as a developer? Briefly
explain your answer.
Answer
(a)
◦ it is harder to write the eventual code for such classes because there are likely to be many
conditional tests to identify the actual state
◦ it is harder to test the classes because of the number of choices of pathway through the
conditional tests
◦ it is much harder for external code to use a class correctly without some means of
ascertaining the actual state of objects belonging to complex classes.

(b) State machines help model what might happen when a particular object receives a given
message because the behaviour of an object is influenced by the values of its attributes. A
state machine tells you about the life history of an object. Therefore you can use the
frequency of change of an attribute during an object’s lifetime as a means of choosing which
attributes are significant when constructing a state machine.
(c) There are situations where you might need to develop state machines retrospectively. In
addition, a proposed change to a software system might introduce a need to prepare one or
more state machine diagrams to show how an object’s state would be affected.
105. SAQ 9
What characteristics of events suggest that object should respond to them when they occur?
Answer
An object should normally respond to: events that are external, such as those from a point-of-
sale terminal change or time events that require some response certain changes, such as a
high or low temperature in a process control system, to avoid problems or even disasters.
Unit 9
106. SAQ 1
Suggest a reason why choosing the architecture very late on might be a bad idea.
Answer
Choosing the architecture at a very late stage suffers from the risks of the waterfall approach.
By then many other design decisions will have been taken and it will be too late to change
them, even if they force us to adopt an architecture that is less than ideal. An analogy could
be with building a house. Would anyone dream of starting construction without an
architectural design for the building?
107. SAQ 7
Where in the hotel system might we use a singleton?
Answer
We could use a singleton instance of HotelChain as a system object that all messages from the
user interface are sent to.
108. SAQ 8
Suggest some quality requirements that the Factory pattern might help satisfy.
Answer
The ones we thought of were maintainability and portability (and flexibility if it is counted as
distinct from maintainability). You may have come up with others.
Page 24
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
Unit 10
109. SAQ 1: Think of another concept that uses principles similar to those above.
Answer
From the above principles, a component closely resembles the concept of an object in an
object-oriented language
110. SAQ 3
Suppose a component is implemented as an instance of a Java class. What corresponds to: the
provided interface of the component the required interface of the component?
Answer
The provided interface consists of all the public methods in the class. The required interface
consists of all the methods from other classes that the component’s methods make use of. In
object-oriented languages an object belonging to a subclass is allowed to replace an object of
the parent class.
111. SAQ 4 / In the context of software components, describe a concept that is similar to
substitutability Components are replaceable: a component can be replaced by another that
does the same job.
Answer
Components are replaceable: component can be replaced by another that does the same job.
112. SAQ 6
Think of situations where the pattern of events for a performance scenario might be:
periodic - sporadic - bursty.
Don’t spend too long on this; it is only meant to get you thinking.
Answer
Periodic: Anything that occurs regularly, for example information sent at the same time each
day from a weather station, or status information sent every minute from a spacecraft.
Sporadic: Messages sent to an address for reporting problems, or signals from a device
monitoring earth tremors.
Bursty: Search queries about a suddenly popular topic, or signals from a device
reporting lightning strikes in a particular area.
113. SAQ 7 - Think of two application areas where the appropriate response measure for
a performance scenario would be something other than latency.
Answer
Here are several examples we thought of: a system controlling a plant processing industrial
chemicals – deadline an online shopping site – throughput an online gaming site – jitter (since
users will expect consistent response times) a social networking site – data loss an online
shopping site – miss rate.

Page 25
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
114. SAQ 8
Invent a usability scenario for a search engine, with the stimulus that the user wants to
minimise the impact of errors.
Answer

115. SAQ 9
From your study of the module, list some other types of reusable solution, apart from design
tactics, that are available to software engineers.
Answer
We thought of: analysis patterns requirements patterns architectural styles design patterns
language idioms components services.
116. SAQ 10
(a) Write down in your own words what flexibility means in relation to software.
(b) What concepts introduced in the module relate to flexibility? Come up with as many as
you can and write them down..
Answer
(a) Flexibility is the ability for software to be changed easily.
(b)
◦ Low coupling so changes don't have knock-on effects.
◦ High cohesion so functions that are closely related can get changed together as a unit.
◦ Hiding implementation behind interfaces and contracts because this keeps coupling as low
as possible.
◦ Use component-based development so components are pluggable/replaceable.
◦ Delegate details such as object creation to factories so clients don't need to know them and
coupling is kept low.
◦ Use layers. Low coupling and separation of concerns.
◦ Wrap legacy software (related to hiding functions behind interfaces).
◦ Package functions as loosely coupled services.
117. SAQ 13
Page 26
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
Read the following information about the hotel system and then sketch on paper a possible way of
building it as a Java EE application, showing what components would be involved, what containers
they would run in and what the communication is. The hotel system will require three types of client:
web clients connecting via the internet, desktop applications installed in hotels, and mobile clients
using tablet and phone apps that connect to RESTful web services. Part of the system must deal with
the core business processes, such as reservations, room lettings, billing and so on. The system will
need to maintain persistent data about customers and hotels

Answer

118. SAQ 15
Suppose the management of the hotel chain decides it would like a way of sending customers
information about special offers. It would also like to be able to send important bulletins to
the application clients installed in the hotels.
(a) Which two Java EE technologies could be used to meet these requirements?
(b) What architectural style are these an example of?
(c) Both these technologies run in the web container. Redraw your sketch of the hotel system
architecture to include them and the associated communication.
Answer
(a) JavaMail and JMS (Java Message Service) respectively.
(b) Notification.
(c) Notice that the application clients are now in communication with JMS in the web
container, as well as with EJBs. Web clients and mobile clients would receive information
about special offers via their normal email systems.

Page 27
TM345 Essay Questions - Unit 6 to 11 Waleed Omar

Unit 11
119. SAQ 1
Suggest three expectations that a customer might have of a software product without
perhaps being aware of them.
Answer
. the product will not conflict with other software that they use
. the product will boost productivity
. the product will be simple to use.
120. SAQ 2
Explain how increasing integrity within a system could affect efficiency. Identify one other pair
of SQFs that are not independent.
Answer
Increasing integrity within a system means strengthening measures to ensure that
modification or deletion of data by unauthorised persons, or by any other unintended means,
does not occur. This might involve the use of passwords to access certain data and an
authentication server to check a user’s identity, or it might mean that network traffic needs to
be encrypted and decrypted. Each of these factors adds an overhead to processing, so
efficiency is likely to be reduced.

Another pair of SQFs that are not independent is usability and portability. For example, many
of the features of the Apple Macintosh that contribute to its reputation for usability are built
into its operating system. Applications that take advantage of these features are less portable
to other systems, such as Windows or Linux.
121. SAQ 3
Give a simple example of two system descriptions that might contradict each other.
Answer
There are numerous possibilities. One elementary example would be if a structural model for
a hotel reservation system indicated that a reservation could be made for more that one room
but the implementation only allowed one room per reservation
Page 28
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
122. SAQ 4
Why is it important for the customer’s requirements statement to be self consistent?
Answer
If the customer’s requirement statement lacks self-consistency, then either the resulting
system will be inconsistent or it will not satisfy the customer’s requirements. The system
builders can decide (implicitly or explicitly) how to resolve the inconsistencies or, if the
inconsistent requirements affect different parts of the system and are not picked up by the
developers, the developers could inadvertently build the inconsistencies into the product
123. SAQ 6
Suppose the following constructor is included in Account.
public Account (int aBalance, int anOverdraftLimit)
{
// initialise an account with a given balance
// and overdraft limit
assert aBalance >= 0 && anOverdraftLimit >= 0;
// body of constructor goes here
assert getBalance() == aBalance &&
getOverdraftLimit() == anOverdraftLimit;
}
(a) Explain the meaning of the pre- and postconditions using natural language.
(b) If assertions are enabled and the following statement is executed what will happen?
Account acc1 = new Account(200, -50);
(c) If assertions are enabled and the following statement is executed what will happen?
Account acc1 = new Account(0, 200);
Answer
(a) The precondition verifies that the arguments aBalance and anOverdraftLimit are both
greater than or equal to zero. The postcondition verifies that the variables balance and
overdraftLimit have been correctly initialised with the values of the corresponding arguments.
(b) A value of -50 for the overdraft limit will mean the boolean expression in the precondition
assertion evaluates to false and an assertion error will be thrown.
(c) The precondition is met and so a new Account will be created with a zero balance and an
overdraft limit of 200.
124. SAQ 10
Why should regression testing be necessary even after the customer has accepted the product
after acceptance testing?
Answer
Acceptance testing is the process of showing that the software meets the customer’s
requirements, not that there aren’t bugs in the code. bugs that require fixing are almost certain
to be found after acceptance testing. the system will be maintained, with functionality added
and changed, leading to a requirement for regression testing.
125. SAQ 11
Use the following phrases, which describe four kinds of testing, to fill the gaps in the following
three sentences. usability testing, requirements testing, security testing, regression testing
TDD and DbC are valuable but not comprehensive tools for _________________.
TDD has ________________ built into it.
DbC and TDD cannot substitute for thorough _______________ or_____________
Page 29
TM345 Essay Questions - Unit 6 to 11 Waleed Omar
Answer
TDD and DbC are valuable but not comprehensive tools for requirements testing.
TDD has regression testing built into it.
DbC and TDD cannot substitute for thorough usability testing or security testing
126. SAQ 17
The WMPC metric measures the complexity of a class in terms of the sum of the cyclomatic
complexities of its methods.
(a) Consider a class with ten methods, whose WMPC value is 40. How confident can you be
that this class is not too complex?
(b) If the WMPC value of a class with ten methods is over 100, how certain can you be that
this class is too complex?
Answer
For individual methods, a cyclomatic complexity of 10 or more should be regarded as a hint
that the method is too complex. In the case of classes, a little more thought is needed.
(a) For a class with ten methods, a value for the WMPC metric of 40 would typically suggest
acceptably low class complexity. However although nearly all of the ten methods might be
acceptably simple, one or two might be unacceptably complex.
(b) By contrast, a complexity of greater than 10 × 10 = 100 is a fair indication that the
behaviour of the class is too complex.

Page 30

You might also like