Software Engineering
Tutor-marked assignment TMA 03 Printable page generated Saturday, 4 Apr 2020, 18:01
Tutor-marked assignment TMA 03
Introduction
Submitting your assignment
This tutor-marked assignment (TM354 TMA 03) must be submitted by 12 noon (UK local time) on 29 April 2020.
This module requires all assignments to be submitted electronically. To submit an assignment, please follow the link(s)
from your StudentHome page to the online TMA/EMA service.
Ensure that you create and submit your answers in a file with an acceptable file format. Acceptable file formats are
those with extensions of .doc, .rtf or .docx. If your word processing software creates a file with a different extension
(e.g. .odt) you should use ‘save as’ then select an option to provide a file with the correct format; otherwise your tutor
may not be able to open your TMA.
It is generally advisable when including diagrams created in word processor applications to ‘group’ the elements of the
diagram together to ensure that your tutor will see what you intended upon opening the file. Alternatively, or in addition
to your main submission, you are permitted to submit a .pdf file for supporting documents only providing that it is
zipped with your main assessment files before submission. You must not submit your main assignment text as a .pdf
file. Your tutor will not mark this if you do.
If you foresee any difficulty with submitting your assignment on time, you should contact your tutor well in advance of
the cut-off date.
For further information about policy, procedure and general submission of assignments please refer to the Assessment
Handbook, which can also be accessed via your StudentHome page.
Mark allocation
The weighting of this assignment is 34 per cent of the continuous assessment score.
This TMA assesses Block 3, as detailed in Table 1.
Table 1 Mark allocation and assessment units
Question Marks Description Units
1 20 stakeholder concerns and architectural styles 9
2 15 design patterns 9
3 35 components, services and quality attribute scenarios 10, 12
4 15 testing 11
5 15 metrics for complexity and coupling 11, 12
Tutor-marked assignment TMA 03: View as single page https://learn2.open.ac.uk/mod/oucontent/view.php?id=1556413&printable=1
1 of 8 4/4/2020, 6:11 PM
Question 1 (20 marks)
a. This question revisits the BillyDoo Software System (BDSS) introduced in TMAs 01 and 02.
i. Identify three groups of stakeholders from the BDSS.
For each stakeholder group, identify one concern that might influence the architecture of the system.
(6 marks)
ii. Briefly discuss the following scenario in terms of any architectural styles that might be involved.
Members of the public can register to receive an email notification whenever a new event is advertised on
BillyDoo that meets some set of criteria. For example they might only be interested in a particular category
and location. By clicking a link in the email they can be taken directly to the BillyDoo page where the event
is advertised.
(4 marks)
b. Think about the computer applications you know and pick one that you consider is a good example of the model-
view-controller (MVC) pattern.
Your example can be a web, desktop, or a mobile application, and it can be something you have used in daily life,
study or work, or even just read about. The choice is yours. The purpose of the question is for you to demonstrate
understanding of the MVC pattern, by showing how it relates to your chosen application.
Briefly describe the application, then go on to identify the model, the view and the controller in the application you
have chosen. Briefly outline what the advantages of the MVC pattern are, using your application as an example.
You should write no more than 160 words for part (b).
(10 marks)
Question 2 (15 marks)
Section 5 of Unit 9 introduced several design patterns – reusable solutions to design problems, at a detailed level.
This question is concerned with a further pattern from the Gang of Four catalogue.
is a structural pattern, whose purpose is to control access to another object, usually described as the real
subject. Clients do not access the real subject directly but via the proxy, which has an identical interface to the real
subject. When the proxy receives a request, it typically performs some additional task or tasks, before forwarding the
request to the real subject. So it can forward requests, the proxy has a reference to the real subject. Figure 1 shows
the general structure of the Proxy pattern. Subject represents the common interface shared by the real subject and the
proxy.
Tutor-marked assignment TMA 03: View as single page https://learn2.open.ac.uk/mod/oucontent/view.php?id=1556413&printable=1
2 of 8 4/4/2020, 6:11 PM
Figure 1 Proxy pattern
Proxies are useful in many different situations. For example, the GoF chapter on Proxy begins with an example of an
image proxy. Suppose we have a word-processed document that contains many large images. If we load them all up
front, then opening the document may be very slow. The solution is to replace each image by a proxy, which can allow
the real image to be loaded only when it needs to be displayed. The proxy knows the dimensions of the real image, so
the word processor can use this information to compute the document layout ahead of the real images being loaded.
An image proxy is a particular example of the type of proxy know as a virtual proxy.
Another example is a protection proxy, which intercepts requests to the real subject and checks that the client sending
the request has the necessary access rights for the action it has requested.
A third category of proxy introduced by the GoF book is a remote proxy. In this case the proxy stands in for an object
that is actually remote and perhaps being accessed over a network. To the client the proxy appears to be a local object
and the proxy hides for the client all the details of the communication with the remote host where the real object is
located.
In this question we look at a virtual proxy, which will be responsible for creating a real subject only when it is actually
required, simulating a situation where the real subject is expensive to create because data must be loaded from an
external source.
a. In the software download associated with this assignment you will find a NetBeans project .
Open this project in NetBeans and run it a few times. You should find that each time it prints a message
containing a well-known saying, like the following
The sayings are picked at random from a list of traditional sayings, which is stored in an external text file
Tutor-marked assignment TMA 03: View as single page https://learn2.open.ac.uk/mod/oucontent/view.php?id=1556413&printable=1
3 of 8 4/4/2020, 6:11 PM
and only loaded into memory when the first saying is requested. At that point the proxy instantiates
a real subject, and the sayings are loaded from the file. The proxy then forwards the request to the real subject,
receives the response, and passes this response back to the client.
Once the real subject has been instantiated the proxy keeps a reference to it and subsequent requests are
forwarded to the same object, the response being passed back to the client as before.
If you open the class and inspect the code, you can see that it first creates a object, which is
assigned to a variable of type . Using the interface type is good practice, because it provides flexibility.
We can replace the proxy by a different one if we decide to in the future, so long as it belongs to a class that
implements .
The client next initiates an interaction by sending the proxy a request, and in due course prints the response it
gets back.
Now open the project . This is the same as , except that we have added a second
request, and in the code of the Proxy class added a print statement to report when a object is
instantiated. Begin by browsing through the three classes and the interface and skim reading their code. The aim
is just to get an overview for what they do and how they fit together, and the details, such as how the contents of
the text file are loaded, are less important.
Then run the project and you should see something like the following, although of course the sayings are likely to
be different.
If you now open the class you can see it is the same as in the previous project, except we now have two
requests. The first request causes a real subject to be instantiated by the proxy, which prints a message reporting
this is being done and then forwards the request to the new object. The second request is simply forwarded to the
real subject already in existence, so the proxy does not print a message the second time round.
Draw a sequence diagram to illustrate the interaction between the client, the proxy, and the real subject, taking
into account the fact that an alternative course of action is involved: if the real subject does not exist, it is created
and then the request is sent to the real subject; otherwise the request is simply sent to the real subject. You can
represent this by using a guard to show that the object creation is conditional. (For an example of using a guard
to show a message being sent conditionally see Figure 2 on p. 146 of Unit 7.)
You will need to show the message answers as well as the messages. Assume the random saying returned is "A
cat can look at a queen."
You do not need to include the creation of the Proxy object, or any of the print statements.
b. (9 marks)
(6 marks)
i. Explain one way in which the Proxy and Adapter pattern are the same, and one way in which they are
different.
ii. Comment briefly on the degree of coupling in the Proxy pattern
iii. Could the Factory pattern be used in conjunction with the Proxy pattern? If so where might it be used?
Tutor-marked assignment TMA 03: View as single page https://learn2.open.ac.uk/mod/oucontent/view.php?id=1556413&printable=1
4 of 8 4/4/2020, 6:11 PM
Question 3 (35 marks)
a. Watch the video of Martin Fowler’s talk on microservices (duration 26:25). If you are using a desktop or laptop
there is a transcript available which can be accessed by clicking the More Options icon … just above the
'SUBSCRIBE' button and selecting 'Open transcript'.
Then answer the following questions, briefly explaining each of your answers. You should write no more than
600 words in total for this part.
(20 marks)
i. What are the main features that distinguish what Fowler calls 'monolithic applications' from those he defines
as 'microservices'?
ii. How are applications 'componentized', i.e. divided up, in a microservices style architecture, as opposed to a
monolithic one?
iii. How are microservices development teams typically organized and how does this contrast with a more
traditional structure?
iv. How do microservice architectures organize data management and what advantages does this approach
bring?
v. Why is monitoring vital in a microservices environment and what is meant by 'designing for failure'?
vi. What are the advantages and disadvantages of a microservices style of architecture as contrasted with a
monolithic style?
vii. What prerequisites are necessary before adopting a microservices approach?
b. Invent either a performance or a usability scenario that could apply to the BillyDoo System.
(7 marks)
i. Your scenario should be presented in a similar manner to the examples in the unit. You will need to pick
suitable values for each of the six parts of the scenario. There are no absolutely right or wrong answers here
although you will need to make sure your choices reflect the system under consideration.
ii. Once you have completed your scenario, make it available to other students in your tutor group via
ShareSpace. You should do this at least 2 weeks before the TMA cut-off date to allow your fellow students
time to comment. Note that you will be unable to view anyone else's scenario until you have uploaded your
own.
iii. Copy your scenario into your TMA document, labelling it: 'My scenario'.
c. Look at the scenarios uploaded by other students. Choose two that are significantly different from yours, and
which, if possible, deal with the opposite quality from yours, i.e. if you wrote a performance scenario try to pick
usability ones; if you wrote a usability scenario try to pick performance ones. In ShareSpace comment briefly on
the other scenarios you selected. In making your comments you should consider factors such as:
• Relevance. Is the requirement that has been chosen a sensible one for the BillyDoo System?
• Clarity. Are the parts of the scenario described clearly and unambiguously?
• Consistency. Are the parts consistent with one another? For example could the chosen source actually
generate the stimulus described?
• Accuracy. Are the parts what they claim to be? For example, is the stimulus actually a stimulus?
• Precision. Is the measure specified precisely enough?
Tutor-marked assignment TMA 03: View as single page https://learn2.open.ac.uk/mod/oucontent/view.php?id=1556413&printable=1
5 of 8 4/4/2020, 6:11 PM
You do not need to address all these aspects, one or two of them will do. Your task is to offer constructive
feedback that will help to improve the scenario.
You should do this at least a week before the TMA cut-off date to allow your fellow students time to make use of
your comments. Aim to write about 150 words of comment per diagram.
Copy both the scenarios you have chosen and your comments on them into your TMA document, labelling each
of them clearly ‘My comments to [your fellow student’s name]’
(4 marks)
d. Read the comments made by fellow students on your own scenario.
Then introduce any changes you wish to make to your scenario and post a new version to ShareSpace. Copy
your updated scenario into your TMA document, labelling it ‘My updated scenario’.
In ShareSpace, add a comment to your new scenario explaining how and why you have improved your original
version. If you did not make any changes, please explain why. Aim to write about 150 words.
Copy your comments into your TMA document, labelling them ‘My comments on improving my scenario’.
(4 marks)
Question 4 (15 marks)
Table 2 Royal Mail price guide for letters
a. The information in Table 2 is taken from the Royal Mail price guide (2019) and defines what size and weight is
allowed for a Letter or a Large Letter.
Not exceeding
Length (cm) Width (cm) Thickness (cm) Weight (g)
Letter 24 16.5 0.5 100
Large Letter 35.3 25 2.5 750
i. Suppose an operation is specified as follows:
Tutor-marked assignment TMA 03: View as single page https://learn2.open.ac.uk/mod/oucontent/view.php?id=1556413&printable=1
6 of 8 4/4/2020, 6:11 PM
Imagine you are asked to design black box tests for this operation. You should assume Design by Contract
is in force.
Describe how you would go about planning the tests and choosing suitable test cases. You are not expected
to generate a full list of tests, just explain what principles you would apply, with a few examples to clarify
your meaning. Also give an estimate of the minimum number of test cases you think are needed, explaining
how you arrived at it.
(8 marks)
ii. The following code snippet is the header of a Java method that implements the operation specified in part (i)
above.
Write down an executable assertion (or assertions, if you prefer to split them) that could be used to verify the
precondition of the method.
(2 marks)
b. Briefly discuss whether or not a Design by Contract approach simplifies unit testing.
You should write no more than 100 words for this part.
(5 marks)
Question 5 (15 marks)
This question is about metrics for complexity and coupling of code.
You are asked to come up with two code samples of your own, and then compare them using two simple metrics for
code complexity:
lines-of-code (LOC)
cyclomatic-complexity.
Although relatively simple, these metrics have stood the test of time and are widely used because they are easily
understood and applied.
Your two code samples should each be equivalent to a Java method of moderate complexity, involving some control
structures such as conditions and loops. The samples should not be too similar to one another. For example you might
look for one sample that had several control structures but was relatively short, and another with more lines of code,
but with simpler control structures.
Your code samples do not have necessarily have to be in Java. The two metrics we ask you to use are not language
specific, and following the details of the calculation is quite easy even in a programming language you are unfamiliar
with. Each sample should however represent a well-defined unit of code, such as a complete method or a function.
Your samples can come from your work or your study, from your reading, or from an internet search. If necessary you
could invent your own examples, although it will obviously be more interesting if you are measuring the complexity of
existing examples.
Be aware that this question is not concerned with the quality of the code examples you use. The only thing that is
Tutor-marked assignment TMA 03: View as single page https://learn2.open.ac.uk/mod/oucontent/view.php?id=1556413&printable=1
7 of 8 4/4/2020, 6:11 PM
Tutor-marked assignment TMA 03 Copyright © 2019, The Open University
important is to choose examples that allow you to show you understand how to use the two metrics, and how to use
the results to draw simple conclusions.
Unless you have written the examples yourself, you should provide a reference for them. The standard for referencing
computer software is given in Subsection 13.1 of the OU Harvard guide to citing references.
If the program is not available via a public URL, instead of 'Available at…' and the URL write 'No public URL available',
but still give the date you accessed the code.
a. Choose your two code samples and copy them into your solution document, labelling them Sample A and Sample
B and indicating their source(s). If from an external source – outside Open University modules – you should give
a full reference.
(4 marks)
b. For both Sample A and Sample B, calculate the value of:
the LOC metric
the cyclomatic-complexity metric.
Calculation of LOC is self-explanatory, but for the cyclomatic-complexity you should show enough working for
your tutor to understand how you arrived at the answer.
(6 marks)
c. Briefly comment on your results from part (b). in a similar way to the answer given for SAQ 15 of Unit 11.
(3 marks)
d. Do your findings suggest either of your samples would benefit from restructuring into smaller units? Briefly explain
your answer.
(2 marks)
References
Royal Mail (2018) Our prices.[Online]. Available at: https://www.royalmail.com/sites/default/files/Our-prices-2018-
effective-26-March-2018.pdf (Accessed: 10 April 2019).
Tutor-marked assignment TMA 03: View as single page https://learn2.open.ac.uk/mod/oucontent/view.php?id=1556413&printable=1
8 of 8 4/4/2020, 6:11 PM