Part 1 Flashcards
A good software system is one that meets its users’ needs. List three characteristics that such a system should possess.
A good software system should be useful, usable, reliable, flexible, affordable and available (any three from this list).
Give two ways in which agile software development can help achieve a good software system.
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.
What is the difference between a functional requirement and a nonfunctional requirement?
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.
What are the advantages of using a standard template, such as the Volere template, for requirements capture?
(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)
What are the benefits of prototyping? Who should test a prototype?
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.
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) 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
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.
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
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.
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.
What is the relationship between stakeholders and architectural views?
An architectural view represents the concerns of a set of stakeholder groups.
What is reused in a framework?
A framework reuses an architecture together with code for components that can slot into that architecture.
How are the Model-view-controller (MVC) and Observer software patterns related?
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.
Suggest one advantage and one disadvantage of developing software by plugging together off-the-shelf components.
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)
What is the difference between a provided and a required interface?
A provided interface describes the operations a component provides to other components. A required interface describes the operations a component requires from other components.
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
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)
Calculate the cyclomatic complexity of the code extract in Table 1 below. Show briefly how you arrived at your answer.
The cyclomatic complexity is 1 (straight through) + 1 (for) + 1 (if) + 1 (&&) = 4.
In test driven development what steps do you need to carry out before you write the code that implements an operation.
Decide on code increment; decide on test; write the test, run the test assuming failure; and only then write the code
(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.
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)
One characteristic of a good software system is maintainability. Briefly
explain the meaning of this term
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.
Give two other characteristics of a good software system. You do not have
to explain them.
Other characteristics of good software system are it meets user’s needs, is useful, usable, reliable, flexible, afordable, avaliable, has low coupling
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 security requitement.
Fit criterion: No unauthorised staff shall be able to access the database.
Briefly explain the advantages of using a standard template, such as the
Volere template, for recording requirements.
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.
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.
Business process:
-General bill
Accept payments
Pay bil
Business rule:
-Cash is accepted only for bills of £15 or less.
(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?
(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.
Copy Figure 1 and add an abstract superclass Employee with Manager and Assistant as its subclasses.
Give • one benefit of using specialisation and generalisation in class diagrams; • one danger of using specialisation and generalisation in class diagrams.
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.
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.
context Assistant inv:
self.department = self.manager.department
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.
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.
Line //* is consistent with the LoD because we are allowed to send messages to objects passed as method parameters.
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) 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
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.
Describe briefly what is meant by defensive programming
Defensive programming means methods check their own preconditions and do not assume this has been done by client.
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.)
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)
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?
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.
What are the benefits of breaking a large software project up into smaller
parts?
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.
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) 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’
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.
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.
Name two aspects of software development for which use case modelling
can be helpful.
To identify what functionality needs to be implemented.
To identify who needs access to the various functions of the software.
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.
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.
Context Team inv:
self.member -> includes(self.captain)
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.
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.
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.
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.
The object being sent a message was created within the method sending the message.
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.
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.
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.
Describe in one or two short sentences how DbC can help with forward
traceability.
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.
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
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?
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.
In component-based development what form does each of the following
take?
Unit testing
Integration testing
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
What effect might using a Service-Oriented Architecture (SOA) have on the
overall amount of testing required?
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.