Part 1 Flashcards

1
Q

A good software system is one that meets its users’ needs. List three characteristics that such a system should possess.

A

A good software system should be useful, usable, reliable, flexible, affordable and available (any three from this list).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give two ways in which agile software development can help achieve a good software system.

A

Agile software development is based on principles such as the ones below which help to achieve some characteristics of a good software system:

 Software should be capable of adapting to change in requirements, helping to achieve a flexible and useful system.

 Software should be delivered on time helping to achieve an available system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between a functional requirement and a nonfunctional requirement?

A

A functional requirement is one that specifies an action the software must perform e.g. check, calculate, record, retrieve etc., whereas a non-functional requirement specifies a quality that the software must possess, e.g. usability, reliability, maintainability etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the advantages of using a standard template, such as the Volere template, for requirements capture?

A

(b) Using a standard template for requirements capture

 saves wasting time repeatedly making decisions about what to record;

 ensures that nothing important is left out;

 assists communication between developers;

 allows projects to be compared and requirements reused in some cases. (any three of these)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the benefits of prototyping? Who should test a prototype?

A

The benefits of prototyping include

 It helps with the design of the user interface;

 it gets the users involved and is a good way of capturing and refining requirements;

 it help minimise misunderstandings between the developer and the users;

 it may allow early detection of possible problems, before things have gone too far, and at a relatively low cost; (any three benefits) [3 marks]

The prototype should be tested by ‘real’ users – those who will be using the software on a day-to-day basis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Is it possible, to identify, using the model in Figure 1, which prescriptions were issued by a doctor? Explain your answer using either English or OCL.

A

(a) Yes, it is possible.

For a given doctor it is possible to find the set of all patients of that doctor following the association between Doctor and Patient; and for a given patient it is possible to find the set of all prescriptions for that patient following the association between Patient and Prescription.

OR

context Doctor: – The set of Prescriptions given by a Doctor of that Clinic. self.patient.prescription

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

For the association loop in Figure 1 find an invariant that should apply to the model. Write the invariant, in the context of the class Clinic, either in OCL or using an unambiguous description in English.

A

The unambiguous English description is shown as a comment in the OCL specification. context Clinic inv: – the set of Patient instances linked to all Doctor instances of the Clinic is the same as the set of Patient instances linked to the Clinic self.doctor.patient = self.patient

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

This question refers to the class model in Figure 1. Suppose we want to implement a use case print prescription. We decide to use Clinic as the system class and implement the use case with a system operation that takes an argument of type Patient, and an argument of type Date (the date of the prescription to print). Draw a sequence diagram showing how this operation could be implemented, inventing suitable names for the methods and parameters required.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In a shared hallway, the light is operated by a press-button switch. Initially, the light is off. Whenever the button is pressed, the light is switched on. As an energy saving measure the light only remains on for 2 minutes after being switched on, then switches itself off again automatically. Draw a statechart diagram for the hallway light, assuming the existence of an event after(2 minutes) that occurs after 2 minutes of remaining in a given state.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the relationship between stakeholders and architectural views?

A

An architectural view represents the concerns of a set of stakeholder groups.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is reused in a framework?

A

A framework reuses an architecture together with code for components that can slot into that architecture.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How are the Model-view-controller (MVC) and Observer software patterns related?

A

In MVC the view needs to be kept updated when the state of the model changes. This can be achieved by using the Observer pattern, with the model as the subject and the view as the observer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Suggest one advantage and one disadvantage of developing software by plugging together off-the-shelf components.

A

Advantages of plugging together off-the-shelf components

 Should be cheaper

 Allows quicker development

 Behaviour of well-tried components will be well understood

 Components are replaceable with other components that have to same interface (any one of these)

Disadvantages

 We will be restricted to the capabilities of the components

 Some additional software is likely to be needed  Adapters may be needed if interfaces are incompatible

 Creating a system from pluggable components may be more difficult than it sounds. (any one of these)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between a provided and a required interface?

A

A provided interface describes the operations a component provides to other components. A required interface describes the operations a component requires from other components.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The usual response measures for a performance scenario are latency, deadline, throughput, jitter, miss rate and data loss. Choose two of these that would be most appropriate in the case of an internet radio service, and briefly explain your answer

A

Latency will affect how quickly a channel can start playing Throughput must be sufficient to stream the service to the user Data loss must be low otherwise some part of the broadcast will be missed (any two of these)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Calculate the cyclomatic complexity of the code extract in Table 1 below. Show briefly how you arrived at your answer.

A

The cyclomatic complexity is 1 (straight through) + 1 (for) + 1 (if) + 1 (&&) = 4.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

In test driven development what steps do you need to carry out before you write the code that implements an operation.

A

Decide on code increment; decide on test; write the test, run the test assuming failure; and only then write the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

(a) Present two situations in which the use of agile development would not be recommended or would be difficult to implement.
(b) Present one situation in which agile developments would be easy to implement.

A

Agile is not recommended or is difficult to implement in the following situations

 Heavily regulated environment – agile is not amenable to heavy regulated documentation

 Predictability is more important than flexibility – agile values flexibility rather than predictability

 Large software development with distributed teams – difficulty to scale has been a constant criticism of agile; distributed teams put a heavy burden on communication which so central to agile  Requirements are well defined and unlikely to change

 Customer is distant –agile demands close involvement of customer (any two of these)

Agile is easy to implement in the following situations

 Requirements are constantly changing – agile deals with well with change

 Developers and users can communicate regularly – agile demands close involvement of developers and users

 The team is small, so that everyone can take part in a single stand-up meeting.

 Team members are disciplined enough not to use “agile” as an excuse for cowboy coding (writing code according to their own rules disregarding what has been agreed by team).

 Developers like being empowered. (any two of these)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

One characteristic of a good software system is maintainability. Briefly
explain the meaning of this term

A

Maintainability is a software quality factor which determines how easily bugs can be found and fixed and how easily it can be adapted to meet its users’ changing needs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Give two other characteristics of a good software system. You do not have
to explain them.

A

Other characteristics of good software system are it meets user’s needs, is useful, usable, reliable, flexible, afordable, avaliable, has low coupling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Consider the following non-functional requirement.
Only authorised staff shall be able to access the customer database.
(i) What category of non-functional requirement is it?
(ii) Suggest a suitable fit criterion for this requirement

A

A security requitement.

Fit criterion: No unauthorised staff shall be able to access the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Briefly explain the advantages of using a standard template, such as the
Volere template, for recording requirements.

A

Advantages of using a standard template for requirements capture (any 3):

  • Systematic list of categories means we won’t overlook some.
  • using a template avoids having to work out what to include each time.
  • Everyone will know what information to expect so its helps communication amongst the developers.
  • It makes it easier to compare projects.
  • It may facilitate reuse of requirements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Consider the following extract from a business description of a pizza delivery
service.
Once a customer has confirmed their order, a bill is generated for the
amount of the order. Customers will be able to pay by credit or debit card, or
by cash, although cash payment will be accepted only if the bill comes to
£15 or less.
From the description identify one business process and one business rule in
this domain.

A

Business process:

-General bill

Accept payments

Pay bil

Business rule:

-Cash is accepted only for bills of £15 or less.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

(b) Give one way in which business rules can be represented.
(1 mark)
(c) Business processes can be represented as UML activity diagrams. What is
the advantage of dividing the activities amongst swimlanes?

A

(b) Ways a business rule can be represented (one asked for)
- In natural language
- Using OCL
- Using constraints or prea- and post conditions.
- Using multiplicities, range of attribute valus, in UML
(c) Swimlanes make it clear whi is responsible for each step.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q
Copy Figure 1 and add an abstract superclass Employee with Manager and
Assistant as its subclasses.
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q
Give
• one benefit of using specialisation and generalisation in class diagrams;
• one danger of using specialisation and generalisation in class diagrams.
A

Specialisation and generalisation has the benefit that it shows were classes have something in common. a potential danger is that substitutability is violated, i.e. we might use specialisation where it’s inappropriate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Using OCL, write an invariant, starting from Assistant, to express the fact
that an assistant and that assistant’s manager must both belong to the same
department.

A

context Assistant inv:

self.department = self.manager.department

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q
The Java code extract below shows a method in the class Employee. The
variable currentDep of type Department is an instance variable of Employee.

public void changeDepartment(Department newDep)

{
currentDep.removeEmployee(this);
newDep.addEmployee(this); //*
this.setDepartment(newDep);
}
(a) Draw a sequence diagram for the interaction that takes place when this
method is invoked on an Employee object ee1, which should be the first
object in the diagram.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

public void changeDepartment(Department newDep)

{
currentDep.removeEmployee(this);
newDep.addEmployee(this); //*
this.setDepartment(newDep);
}

(b)
Is the line marked //* consistent with the Law of Demeter? Explain your
answer.

A

Line //* is consistent with the LoD because we are allowed to send messages to objects passed as method parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

An electric toothbrush has a single press-button control and two operating
speeds, normal and fast. Pressing the button sets the toothbrush running at
normal speed. Pressing the button again increases the speed to fast. From fast, if
the button is pressed the toothbrush is switched off.
While the toothbrush is running, at either speed, it pauses for one second after
every 30 seconds to help the user know how long they have been brushing. After
the one-second pause the toothbrush resumes running at the same speed as
before the pause.
Draw a statechart diagram to illustrate the states of the toothbrush and the
transitions between them. You do not need to show an exit state.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

(a) Suppose classes AccountA, AccountB and AccountC model bank
accounts that pay an annual bonus if the balance of the account never falls
below a certain level during a 12 month period.
• AccountA pays a bonus of £50 if the balance never falls below £500.
• AccountB extends AccountA and pays a bonus of £100 if the balance
never falls below £1000.
• AccountC extends AccountB and pays a bonus of £75 if the balance
never falls below £500.
Apart from the differences given above, the three types of account are the
same.
Explain whether or not
(i) Instances of AccountB can be substituted for ones of type AccountA.
(ii) Instances of AccountC can be substituted for ones of type AccountB.
(iii) Instances of AccountC can be substituted for ones of type AccountA

A

Instances of AccountB for accountA: no bacause AccountB has a stronger precondition than AccountA OR A client expecting AccountA would be entitled to a bonus if the minimum balacnce were between £500 and £1000, but if AccountB were sunstituted no bonus would be paid.

Instances of AccountC for AccountB: No because AccountC has a weaker postcondition than AccountB OR A client expecting AccountB would be entitled a bonus 0f £100 in the minimum balance were at least £1000 but if AccountC were sunstituted only £75 would be paid.

Instances of AccountC for AccountA: Yes because AccountC has the same precondition as AccountA and a stronger postcondition OR Yes because a client expecting AccountA would be entitled to a bonus of £50 if the minimum balance were at least £500 but would in fact receive £75 if AccountC were substituted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Describe briefly what is meant by defensive programming

A

Defensive programming means methods check their own preconditions and do not assume this has been done by client.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

a) Explain briefly how the Model-View-Controller (MVC) pattern can be applied
to this gadget, saying what is the model, what is the view and what is the
controller.
(2 marks)
(b) In what way does the MVC pattern promote flexibility?

A

a.)

Model - the program that does the conversion

View - is the screen displaying the results

Controller - is the entry screen

b.) MVC promotes flexibility because we can keep the Model the same and change the View and Coltroller (i.e. the presentation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Compare the complexities of the following two pieces of code in Table 1 using the
LOC and cyclomatic-complexity metrics, showing how you calculated the
cyclomatic complexity in each case. What conclusion do you draw about the
relative complexity of A and B?

A

LOC metric is 5

Cyclomatic-complecity metric for A is 1 (straight-through) +1 (if) +1 (if) = 3

Cyclomatic-complexity metric for B is 1 (straight-through) + 1 (for) + 1 (if) + 1 (||) = 4

B is more complex.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

What are the benefits of breaking a large software project up into smaller
parts?

A

There is a limit to how much a person can understand at one time. So by splitting a project up it is possible to identify more manageable tasks for those involved.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Consider the following three requirements
(a) The product shall operate under water at depths up to 200 m.
(b) The product shall enable a user to view a list of all the music downloads
they have purchased in the last 12 months.
(c) The product shall be usable via spoken commands.
For each requirement in turn:
say whether it is functional or non-functional;
suggest a suitable fit criterion for it.

A

a) Functional. Fit criterion: ‘It should be possible to carry out operation X, Y, Z whilst the product is submerged to 200m in water’
b) Functional. Fit criterion: ‘A user should be able to see a list of all of the music downloads from the last 12 months’
c) Non-functional. Fit criterion: ‘A user should be able to speak one of a set of commands and the system should carry out the related function in 90% of the time’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Consider the following extract from a business description of a tennis club.
Members can make bookings for court sessions by internet or
telephone. Internet bookings may be made at any time but telephone
bookings are restricted to office hours.
Bookings can be cancelled by internet at any time by or by telephone
during office hours, but if a cancellation is made less than 24 hours
before the session booked, the member must pay a cancellation fee.
From the description identify two business processes and two business
rules in this domain.

A

Processes

Members can make bookings via the internet.

Members can cancel bookings via the telephone.

Rules

Telephone bookings can only be made during office hours.

A booking cancelled within 24 hours of the session is subject to a cancellation fee.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Name two aspects of software development for which use case modelling
can be helpful.

A

To identify what functionality needs to be implemented.

To identify who needs access to the various functions of the software.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q
Using generalisation, draw a fragment of a class diagram showing that a
current account and a savings account are both a kind of bank account.
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q
Consider the class diagram shown in Figure 1 and state an invariant that
arises from the loop between the two classes. You may write the invariant
using either OCL or unambiguous English.
State any assumptions you make about the domain.
A

Context Team inv:

self.member -> includes(self.captain)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q
Sometimes an association between two classes can be derived from other
elements in the model. Suggest a reason why – even though an association
is derived – you might still decide to retain it in the class diagram.
A

Including a derived association in a diagram makes it clearer to those looking at the diagram that there is some kind of association even if it doesn’t need to be implemented as such.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q
public void printBill(Room room) {
Bill bill = room.getBill();
PrintJob job = new PrintJob(bill);
job.start(); // \*
}

Draw a communication diagram for the interaction that takes place in the
body of the method shown.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q
public void printBill(Room room) {
Bill bill = room.getBill();
PrintJob job = new PrintJob(bill);
job.start(); // \*
}

The line marked // * is consistent with the Law of Demeter. Explain why.

A

The object being sent a message was created within the method sending the message.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

A temperature warning light on a machine can be green, amber or red.
When the machine is first switched on the light is green and it remains green
while the machine is running normally. If the temperature of the machine reaches
80°C or more, the light changes to amber. If the light is amber and the
temperature drops back below 80°C the light returns to green. If the light is
amber and the temperature reaches 90°C or more, the light turns red, and
remains red whatever the temperature, until the operator presses a Reset button,
when it returns to green.
Draw a statechart diagram to illustrate the states of the warning light and the
transitions between them. You do not need to show an exit state.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Suppose three classes are defined as follows.
Calculator1 has two methods add() and subtract(). Each of these
methods accepts as arguments a pair of numbers which must be in the
range 1 to 10,000,000 inclusive and returns the result of the corresponding
arithmetical operation.
Calculator2 extends Calculator1 and has two extra methods
multiply() and divide(). All four methods in Calculator2 accept a
pair of numbers which must be in the range 1 to 1,000,000 inclusive and
return the result of the corresponding arithmetical operation.
Calculator3 extends Calculator2 and has the same four methods
except they are redefined so they now accept numbers in the range 1 to
100,000,000 inclusive and as before return the result of the corresponding
arithmetical operation.
Assume Design by Contract (DbC) is being used:
Can instances of Calculator2 be substituted for ones of type
Calculator1?
Can instances of Calculator3 be substituted for ones of type
Calculator2?
Explain your answers.

A

Instances of Calulator2 cannot be substituted for ones of type Calculator1 as the constraints of Calculator2 are stronger than those of Calculator1.

Instances of Calculator3 can be substituted for ones of type Calculator2 as the constraints of Calculator3 are weaker than those of Calculator2.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

Describe in one or two short sentences how DbC can help with forward
traceability.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Google mobile maps is a program that allows a user to search for a location
by speaking the name of a place, for example ‘Cape Town’, into a mobile
phone.
The software uses a speech-recognition system to try and identify the
location the user has asked for, then retrieves the corresponding map and
displays it on the screen of the mobile phone.
Explain briefly how the Model–View–Controller (MVC) pattern applies to this
software, saying what is the model, what the view and what the controller.

A

Model:The store of maps and the process of retrieving a map, View: This is where the map is displayed on screen, Controller: The speech recognition software

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

Suppose an application offers various different views, for example:
a standard version
a version for blind users who use a screen reader to convert words into
sound
a mobile version adapted to a small screen.
How could the Factory pattern be useful in this application?

A

The factory pattern can be used as a shared resource to create the controller objects required by the views. This encourages reuse of code and also decouples the process from the view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

In component-based development what form does each of the following
take?
Unit testing
Integration testing

A

Unit testing: This is used to verify each component on its own against the requirements

Integration testing: this is required to verify that the components work together to meet the requirements after unit testing is complete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

What effect might using a Service-Oriented Architecture (SOA) have on the
overall amount of testing required?

A

An SOA should reduce the overall amount of testing required as each component will be tested to make sure it correctly performs to its own API.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

In software development, what does iterative development mean and how
does it contrast with the waterfall model?

A

Iterative development uses short cyclical steps to develop small portions of the software in each iteration. Once an iteration is finished a new one is started on the next part of the software. In contrast a waterfall model moves through the steps of development one at a time and will not return to previous steps. Iterative development allows for problems to be identified earlier and resolved more easily whereas a water fall model may not identify problems until late in the development process making it more difficult to resolve.

52
Q

Give one reason why a software system might not meet the needs of its
users when it is delivered.

A

The business processes may have changed since the software was first commissioned.

53
Q

What do usability requirements describe?

A

Usability requirements are non-functional requirements that describe how well the users must be able to use the system. This could include how easy the system is to learn or how quickly a user can perform a given task.

54
Q

What is a fit criterion and who will use it?

A

A fit criterion is a statement that describes a requirement in a precise and measurable way. It is used by anyone testing the system so that they can check the system fulfils the given requirement.

55
Q

(a) In a use case diagram, what does an actor represent?
(b) How is a scenario related to a use case?
(c) In an activity diagram, what is the advantage of showing swimlanes?

A

a) An actor represents a user or another system that interacts with this system.
b) A scenario represents one particular example of how a use case unfolds.
c) An advantage of swim lanes is that they clearly show which roles are responsible for each of the actions in an activity diagram.

56
Q

(a) In Figure 1 the association between Repair and Payment is shown as
derived. Explain briefly the meaning of a derived association, using the
association in Figure 1 as an example.
(b) Using either OCL or an unambiguous description in English, write down an
invariant involving the three classes Invoice, Repair and Customer and the
associations between them, starting at Invoice.
(c) Suppose that, in the example shown in Figure 1, customers have a unique
customer number. How could the class diagram be modified to capture this
information? (You should either describe the modification in words, or draw
a sketch to show how the relevant part of the diagram would be changed.)

A

a) A derived association is one that does not need to be explicitly recorded as it can be worked out from other information. In the example given Repair is associated with exactly one Invoice. If a payment has been made this one Invoice will be associated with exactly one Payment, therefore this payment can be trace from Repair to Invoice to Payment. This will be the same Payment that would be linked via the derived payment association.
b) Context Invoice inv:
self. repair.customer = self.customer
c) Add an attribute to the Customer class of customerNumber. Change the associations to Customer to qualified associations by adding a customerNumber box to the association at the end opposite the customer Class.

57
Q

Explain which of these alternatives, 2a or 2b, is not allowed by the
guidelines of the Law of Demeter, assuming Company has no direct
association with Employee.

A

Figure 2b since Employee is not known to the Company object and it is not a parameter of the getName method and it is not created in the method. Deleter does nor allow sending messages to objects that are returned as a result of other messages

58
Q

(b) What sorts of model element can be grouped into a UML package?
(c) Briefly define the term namespace.

A

b) A UML package is a way of grouping model elements together to reduce complexity in diagrams. These could be classes, use cases, associations or other packages.

(This is sort of answered in Block 2 p184 SAQ10 (a) which I nicked part of my answer from. So I think this is TM354)

c) Each package will have its own namespace which allows elements in different packages to have the same name. The namespace of the containing package makes the name of the contained element unique.

59
Q

The following statements refer to the inbox of a particular email system.
• Incoming messages begin as unread.
• The user may delete a message without reading it; read the message; or
leave it unread.
• When the user reads a message it is marked as read.
• Once a message is read, the user can delete it, move it to an archive, or
leave it as a read message in the inbox.
• Deleted messages cannot be undeleted.
• If a read message has remained in the inbox for one year without being
archived it is deleted automatically by the system.
Draw a statechart diagram to illustrate the lifecycle of a message.

A
60
Q

A bank may offer its investors savings accounts, which pay an annual bonus
provided no more than a certain number of withdrawals have been made from the
account during the year.
(a) Suppose the class SavingsAccount has two subclasses
BonusSavingsAccount and FlexibleSavingsAccount.
All three accounts receive an annual bonus payment which depends on the
number of withdrawals the account holder has made during the year.
• A savings account pays a 2% bonus providing the account holder has made
no more than two withdrawals during the year,
• A bonus savings account pays a 3% bonus providing the account holder has
made no more than one withdrawal during the year,
• A flexible savings account pays a 1% bonus providing the account holder has
made no more than three withdrawals during the year.
• Apart from the differences given above, the three types of account are the
same.
(i) Can an instance of BonusSavingsAccount be substituted for an
instance of type SavingsAccount? Justify your answer.
(ii) Can an instance of FlexibleSavingsAccount be substituted for an
instance of type SavingsAccount? Justify your answer.

A

ai) No as the BonusSavingsAccount has stronger pre conditions than the SavingsAccount and is therefore harder to satisfy
aii) No. Although the FlexibleSavingsAccount has weaker pre conditions than the Savings account and is therefore easier to satisfy, the post condition of the FlexibleSavings account is weaker (or worse) at 1% than the Savings account at 2%

61
Q

Explain briefly what a class invariant is.

A

A class invariant is a condition that must hold true for the class at all times that the class is observable.

62
Q

Suppose you are developing an application with two layers, a presentation layer
and a business layer, and your design uses the Model-View-Controller (MVC)
pattern.
(a) Which layer should each of the MVC roles – model, view and controller – be
placed in?

A

Presentation: view, controller. Business: model

63
Q

Explain how a layered architecture promotes reuse.

A

A layer architecture promotes reuse by allow the various layers to be used again as components in different projects (or even the same project). For example the business layer of a traditional desktop application could be reused with a new presentation layer to make the application accessible via a web interface.

64
Q

What is the difference between black box tests and white box tests?

A

lack box testing does not concern itself with the inner workings of the code to be tested. It will use the pre- and post-conditions to verify that for a given set of inputs the right outputs are generated.

White box testing analyses the internal workings of the code to be tested to make sure all possible paths through are tested and generate the right output.

65
Q

What do the terms unit testing and regression testing mean?

A

Unit testing uses automated tools to test individual methods in a class to verify their correctness.

Regression testing tests the software on a regular basis to make sure any code changes do not break already working and verified parts.

66
Q

Describe briefly what is meant by an incremental approach to software
development and state one advantage of such an approach

A

With an incremental approach to software development the team starts with a subset of the requirements and the system is grown incrementally with feedback during each iteration. Each iteration can be considered to be a mini-project that involves, requirements gathering, development and testing with feedback from the stakeholders. This is in contrast with a waterfall approach where all of the requirements are gathered up front

67
Q

How does using a standard modelling language – such as UML – contribute
to software development?

A

A standard modelling language such as UML allows project members to concentrate on the subject matter of communication rather than on the means of communication. This allows project newcomers to concentrate immediately on the project itself rather than learning the forms of communication.

68
Q

What is the purpose of a requirements document?

A

With an incremental approach to software development the team starts with a subset of the requirements and the system is grown incrementally with feedback during each iteration. Each iteration can be considered to be a mini-project that involves, requirements gathering, development and testing with feedback from the stakeholders. This is in contrast with a waterfall approach where all of the requirements are gathered up front

69
Q

What would be an appropriate fit criterion for a functional requirement?

A

An appropriate fit criterion for a functional requirement would be a precise, measurable and testable statement that gives a yes or no answer. An example would be: ‘The system shall notify the user when a given product reaches its low stock level’.

70
Q

What is the advantage of showing swimlanes in an activity diagram?

A

The advantage of showing swim lanes in an activity diagram is that is it clear to see which role undertakes each action.

71
Q

State one possible problem that may arise when developing a software
system from a set of use cases.

A

The use cases may stray too far towards showing detailed implementation rather than a top level view of what actions actors should be able to perform.

72
Q

Can the association between Developer and Project with roles developer
and currentProject be derived from the other associations in the diagram?
Briefly justify your answer.

A

The associations are bidirectional as there are no arrowheads on any associations. Thus the relationship between Developer and Project in both directions can be identified (i.e. reached through the Increment object)

  • currentProject: the set of Increments a specific Developer is currently working on can be identified and then the single Project that each of those Increments is associated with can be identified
  • developer: the set of Increments making up individual projects can be identified and then the Developers of each Increment (and thus Project) can be reached.
73
Q

Using either OCL or an unambiguous description in English, write down an
invariant involving the two classes Project and Developer and the two
associations between them.

A

Context Project inv:

self.developer -> includes(self.teamLeader)

Context Project inv:

self.developer -> includesAll(self.increment.developer)

74
Q

Suppose that each developer is either an analyst, a programmer or a tester,
and that at least one developer of each type must be involved in each
increment. Describe how the diagram could be altered to express this fact
using specialisation. (You are not required to redraw the diagram. You may
do so if you wish, but it is sufficient to describe the changes you would
make.)

A

Remove the developer/currentProject association. Add three subclasses of developer: analyst, programmer and tester. Add an association from Project to each of these with a one or more (1..*) multiplicity at the end closest to Analyst, Programmer and Tester.

75
Q

This question refers to the class diagram in Figure 1 above.
Imagine we want to implement use case assign developer to increment for an
instance of Developer and an instance of Increment having the following pre- and
postconditions.
Precondition:
The instance of the class Developer is linked to an instance of the class
Project;
The instance of the class Increment is linked to the same instance of the
class Project.
Postcondition:
The instance of the class Developer and the instance of the class
Increment will have been linked.
This use case requires the following operations (Table 1).
Table 1
Class | Operation
Developer | addIncrement(i : Increment)
Increment | addDeveloper(d : Developer)
(a) Draw a pair of object diagrams, before and after, to illustrate the effect of the
use case.

A
76
Q

This question refers to the class diagram in Figure 1 above.
Imagine we want to implement use case assign developer to increment for an
instance of Developer and an instance of Increment having the following pre- and
postconditions.
Precondition:
The instance of the class Developer is linked to an instance of the class
Project;
The instance of the class Increment is linked to the same instance of the
class Project.
Postcondition:
The instance of the class Developer and the instance of the class
Increment will have been linked.
This use case requires the following operations (Table 1).
Table 1
Class | Operation
Developer | addIncrement(i : Increment)
Increment | addDeveloper(d : Developer)

(b) Assuming the association between Developer and Increment is
bidirectional, there will be a consistency requirement. If for example
developer d2 is linked to increment i3, then i3 must be linked to d2.
What suggestion do the GRASP patterns offer for handling this requirement
and what would this mean in terms of the operations in Table 1?

(c) How might the design decision identified in part (b) be enforced, if the
programming language used to implement the system were Java?

A

(b)

Make one of the two classes responsible for creating the links at both ends. For example, make the Developer response by adding an Increment to a Developer; the Developer should now add itself to the Increment. (I’m not sure this actually answers the question being asked)

(c) Give the addIncrement method a public access modifier; give the addDeveloper method a packack-private modifier (no modifier in Java).

77
Q

When a customer opens a new online e-savings account with the Notlaw Building
Society they are sent a username and a temporary password that can be used
just once. Before they can use the new account they must activate it, which
involves logging in and setting a new password. If the user does not do this within
80 days the account is closed. Once activated, an account remains live until
closed by one of the parties involved.
Consider a class Account that represents such accounts. Draw a statechart
diagram to illustrate the lifecycle of an instance of Account.

A
78
Q

Suppose a system is being developed using Design by Contract and Java

assertions. When a method is tested, a postcondition assertion error is
thrown. Where would you look for the cause of the error?

A

In the method being tested.

79
Q

Give a definition of the term class invariant.

A

A class invariant is a condition that any valid object of a class should satisfy at all times from its creation onwards, when the state is observable by other objects.

80
Q
Do clients have a responsibility for upholding class invariants? Briefly
explain your answer.
A

No. The class itself has the responsibility that its invariants are always true. Clients should never be allowed to put the class into an illegal state.

81
Q

Give one advantage of using an architecture that follows the Layers
pattern.

A

Segregation of concerns allowing each layer to concentrate on one thing.

82
Q

If the Model View Controller design pattern is used in a layered
architecture, which roles are located in the presentation layer and
which in the business layer?

A

Presentation layer: view, controller. Business layer: model.

83
Q

How does separating presentation from business logic help when it comes
to testing?

A

User interfaces are normally tested manually, whereas testing business logic can be done by automated tools. Separating these will make the user interface testing easier since it doesn’t also need in test the business logic.

84
Q

State which of the following testing types belong to validation and which to
verification; justify your answer.
• unit testing;
• integration testing;
• system testing;
• acceptance testing.

A

Unit testing: verification

Integration testing: verification

System testing: verification

Acceptance testing: validation

85
Q

How might component-based development reduce the amount of testing
required?

A

Although there may be an increase on the amount of integration testing required, if any of the components are being reused or are standard components then these should already have been well tested

86
Q

Give two reasons why the Unified Modelling Language (UML) is a useful
standard.

A

It has been widely adopted in the industry which means that it is very likely that most, if not all members of a development team will be familiar with it which will help with communication. It is a general purpose language for software development that is not linked to any particular methodology.

87
Q

What is the purpose of domain modelling?

A

To understand the environment in which the system will be used, namely the business rules and processes.

88
Q

Briefly say why a software development company might specialise in a
particular type of business, such as health care or e-commerce.

A

Overtime they will build up domain expertise in that area. They may also amass code and components that are specific to that type of business that they can reuse.

89
Q

Why is requirements documentation important?

A

It helps to confirm to the stake holders what is going to be built, it is a starting point for the development team and ultimately it can be used to verify that the system is doing what it was intended to do.

to faciliate traceability between requirements and coding,

to ensure that all requirements have been implemented,

in some regulated areas it is legally required.

90
Q

Comment on the way the following requirement has been expressed.
Users must be able to learn the system quickly.

A

This is an example of a non-functional requirement of the system, but it lacks a suitable fit criterion that would help to measure the success of the system against this. A more suitable requirement might be. ‘Users should be able to perform task X without error after a five minute lesson on the subject”

91
Q

Give two reasons why requirements may evolve.

A

Business practices may change. Legislation may be changed.

92
Q

What is meant by a business rule?

A

A business rule reflects a constraint in the business domain.

93
Q

What does an actor in a use case diagram represent?

A

A person or another system that will interact with this system.

94
Q

How is a scenario related to a use case?

A

A scenario shows one way in which a use case can unfold.

95
Q
Can the association between Tutor and Student be derived from the other
associations in the class diagram? Briefly justify your answer.
A

No. The student is linked to only one department but that department can be linked to many tutors and not a specific tutor. Likewise the student is linked to one course but that course can also be linked to many tutors.

96
Q

The tutor who tutors a student must tutor the course on which the student is
enrolled. By considering the loop of associations, identify a problem with the
model and, using either OCL or an unambiguous description in English,
write down an invariant involving the three classes Tutor, Course and
Student and the associations between them, starting at Tutor.

A

Context Tutor inv:

self.Student.Course = self.Course

97
Q

This question refers to the class model in Figure 1 above.
Imagine you are required to implement a use case appoint tutor to course having
the following pre- and postconditions.
Precondition:
The instance of the class Tutor is linked to an instance of the class
Department.
The instance of the class Course is linked to the same instance of the class
Department.
Postcondition:
The instance of the class Tutor and the instance of the class Course will
have been linked.
(a) Draw a pair of object diagrams, before and after, to illustrate the effect of the
use case.

A
98
Q
Figures 2(a) and 2(b) show the interactions for two alternative ways of
implementing the use case.

Which of the above solutions would the GRASP patterns recommend using,
and for what reason?

A

The GRASP patterns would recommend using Figure 2(a) as Tutor has an association with Course and is the expert in relation to this association, therefore, Tutor should be the one to administer it.

99
Q

An electric kettle for boiling water is controlled by an on-off switch and a
thermostat.
Initially the kettle is switched off. Heating of the water commences when the user
switches the kettle on manually. The kettle remains on until either the user
switches it off manually, or the temperature of the water reaches boiling point of
100°C, when the thermostat switches the kettle off.
Draw a statechart diagram to illustrate the behaviour of the kettle.

A
100
Q

In this question assume Design by Contract (DbC) is being used.
(a) Suggest two benefits of using assertions.

A

Assertions provide accurate documentation for the implemented classes so that a programmer knows how to use them and what to expect from them. In addition to this, if they are executable then can be an important aid to testing.

101
Q

Suppose the class PremiumBonusAccount is a subclass of class
BonusAccount and a method addBonus() is defined in class
BonusAccount and redefined in PremiumBonusAccount. There is no
other difference between the two classes.
The two specifications of the addBonus()method are shown in Figure 3
below. Explain whether or not instances of PremiumBonusAccount can be
substituted for ones of type BonusAccount.

A

Yes they can. The addBonus method of the PremiumBonusAccount class has weaker restrictions than those given by BonusAccount and therefore can be substituted.

102
Q

Say briefly what is meant by the inertial convention.

A

Inertial convention refers to the fact that the various components of an object that have not been specifically stated in the post-condition will remain unchanged.

103
Q

Explain how the Observer pattern might be applied in a Model-View-
Controller (MVC) design.

A

The view will register with the model to be notified of changes. When the model changes it will notify the view and the view can then update the information displayed.

104
Q

An important feature of a service in a service-oriented architecture (SOA) is
that it is discoverable. Briefly explain what this means.

A

A discoverable service means that the service is registered with a directory and a client can search this directory to access and find details of the service

105
Q

What is the relationship between system testing and acceptance testing?

A

System testing is generally done just prior to acceptance testing and is used to verify the system against the documented requirements. Acceptance testing is then used to validate the system against the stakeholder’s expectations.

106
Q

Calculate the cyclomatic complexity of the code sample in Figure 4, briefly
showing your working.

A

b) Complexity of 4.

  1. Initial path
  2. while loop
  3. && operator
  4. if condition
107
Q

How is the cyclomatic complexity metric relevant to white-box testing?

A

White-box testing looks at the internal structure of a method and therefore the cyclomatic complexity has a direct relationship to how many different paths of execution there are that require testing

108
Q

(a)
(ii) In the context of project planning, indicate briefly what is meant by
timeboxing.

A

Time boxing refers to breaking down development into iterations of a certain length of time.

109
Q

Name any two characteristics that a good software system should possess,
and explain the meaning of each in a single sentence per characteristic.

A

usefulness -meets the user’s needs

maintainability - how easily errors can be found and fixed

reliability - errors are minimized

110
Q

What kind of software system might be best suited to incremental
development?

A

Software systems where the problem can grow incrementally or where it fails naturally into partitions, each of which represents a fairly self-contained unit that could be developed and delivered on its own to provide the users with a useful chunk of functionality, would be well suited to this model.

An Interative and incremental approach allows several design issues to be tackeled simultaneously and enables the system to be implemented in relatively small steps in order to contain the complexity. Of course, this assumes that the design can be partitioned.

111
Q

(a) Consider the following description of a non-functional requirement.
• New members shall be able to register as quickly as possible.
(i) What category of non-functional requirement is it?
(ii) Suggest a suitable fit criterion for this requirement.

A

(i) A usability (or peformance) requirement
(ii) Fit criterion: 95% of new member shall succeed in registering within 3 minutes.

112
Q

Explain briefly how prototyping can contribute to software development.

A

To answer questions about a proposed system … a prototype can be built and evaluated by the customer.

113
Q

(a) Consider the following extract from a business description of an online shop.
At checkout new customers must register for an account and supply
payment details before they can complete their purchase. Customers who
already have an account can pay using the details they entered previously.
Any changes to the order or shipping information must be made within 1
hour of having made the order. Once the order has been made the customer
is sent a confirmation via email.
From the description identify one business process and one business rule in
this domain.

A

business processes:

  • register for an account
  • supply payment details
  • pay using the details they entered previously

business rules:

  • new customers must register for an account
  • before they can complete their purchase

-Any changes to the order or shipping information must be made within 1
hour

114
Q

Why are synchronisation bars used in an activity diagram?

A

To show activities being carried out in parallel (i.e. concurrently)

115
Q

What is validation of a business rule and how would it be done?

A

Validation of business rule means ensuring it is the right rule. It is performed by consulting the stakeholders.

116
Q

(a) Figure 1 shows Payment generalises CashPayment and CardPayment.
Give one advantage of using generalisation/specialisation relationships in
class models.

A
  1. to show features classes have in common
  2. to show that one class represents a subtype of another
117
Q
Does this class model allow us to find out which member was responsible
for a given cash payment? Briefly explain your answer.
A

No. A CashPayment is a type of Payment, so it is linked to 1 or more Tickets. Whilst each Ticket is linked to exacly 1 Member we cannot tell which (if any) of them paid for the Tickets.

118
Q

(i) Write down a navigational relationship which refers to the collection of
showings a member has attended.
(ii) Using OCL write down an invariant which expresses the constraint that
the collections of showings of films which a member has seen must
include the collection of showings for which the member has bought a
ticket.

A

(i) self.ticket.showing
(ii) context Member inv:
self. film.showing -> includes(self.ticket.showing)

119
Q

This question refers to the class diagram fragment in Figure 1 above.
Imagine we want to implement an operation with the following specification
context Society::cancelTicket(ticket : Ticket)
pre:
– ticket is not linked to a Payment object
post:
– all links to ticket will have been removed
Table 1 shows the Java code for a possible implementation in class Society.

(a) Draw a pair of object diagrams, before and immediately after, to illustrate the
effect of the cancelTicket operation.

A
120
Q

(b) Is the code shown in Table 1 consistent with the Law of Demeter? Explain
your answer.

A

No because a message is sent to showing which was the answer to an earlier message… and not a variable “known” to the methid passed to the method

121
Q

This question refers to the class diagram fragment in Figure 1 above.
Imagine we want to implement an operation with the following specification
context Society::cancelTicket(ticket : Ticket)
pre:
– ticket is not linked to a Payment object
post:
– all links to ticket will have been removed
Table 1 shows the Java code for a possible implementation in class Society.

(c)Draw a communication diagram for the interaction that takes place when the
message cancelTicket(Ticket ticket) is sent to a Society object
society, which should be the first object in the diagram.
A
122
Q

A set of traffic lights at a pedestrian crossing operates as follows.
• Initially the lights are green
• When a pedestrian presses the button the lights turn to amber for 5 seconds,
and then to red
• After 20 seconds at red the lights change to flashing amber for a further 10
seconds
• The lights then return to green.
Draw a statechart diagram to show the states the traffic lights can be in and the
transitions between them.

A
123
Q

Suppose ClassA has a method stringArrayToSet which accepts an array of
strings and returns a set containing the elements of the array, not ordered in any
special way.
ClassB extends ClassA and overrides stringArrayToSet so that in the set
that is returned the strings are arranged in ascending alphabetical order.
There are no other differences between ClassA and ClassB.
Explain whether or not an object of ClassB can be substituted for one of ClassA
without undermining the subtyping relationship.

A

A client expecting an object of ClassA will not care how the strings are stored.

If an object of ClassB is used instead the string will be in alphabetical order but this will not affect the client.

Therefore object of ClassB are substitutable for once of ClassA.

124
Q

Give one disadvantage of the Layers pattern

A
  1. Information may need to be replicated across different layers.
  2. Data has to be transformed at each layer which affects performance.
125
Q

Explain how separation of concerns applies to the Model–View–Controller
(MVC) pattern.

A
  1. The Model, View and Controller each have a distinct role
  2. The Model is responsible for storing and processing domain information.
  3. The View displays the information in a visual form
  4. The controller is responsible for hadling user input and communicating it ti the Model.
126
Q

Calculate the cyclomatic complexity of the code extract in Table 2 below,
showing briefly how you arrived at your answer.

A
  1. 1 (straight - through)
  2. +1 (if)
  3. +1(for)
  4. +1(if)
  5. +1(||)

So cyclomatic complexity = 5

127
Q

An alternative measure of complexity is the lines-of-code (LOC) metric,
which simply counts the number of lines in the code.
Briefly explain why LOC might be unreliable as an estimate of complexity.

A

Because factors such as code style and whether comments are included might make a big difference to the number of lines of code whithout reflecting any real difference to the complexity.