Revision Questions
Revision Questions
Software design is the activity of specifying the nature and composition of software
products that satisfy a client’s needs and desires, subject to the project’s constraints. Today,
software is a huge part of almost everyone’s day to day lives and good design literally is
economically important and affects our quality of life because of it, meaning that software
design has important consequences that software designers need to be aware of.
Software product design refers to specifying software product features, capabilities and
interfaces in line with client needs and requirements. This requires UX, UI skills,
communications, industrial design and marketing. Output of this process is the SRS.
Software engineering design refers to the designing of programs and sub-systems and their
specific parts and workings to meet the product specification. This requires programming,
software engineering skills etc.
Observation – designers watch and observe how users are currently working. It’s good for
recording how users use the software to generate ideas. It’s more effective and natural than
having people explain their work, but it may not be comfortable for some workers so they
might not act 100% genuine.
Document studies – look at existing documents and try to understand it. E.g. books,
development documentation, bug reports, policies etc. Can go with observation to build a
better picture of how they currently work.
Market research – look at existing similar products that may give you a better understanding
of the system you need to build.
Modelling – can help to represent the problem and help designers understand it. E.g. UML
diagrams, use case descriptions.
Refer to the product mission statement for the Computer Assignment System (CAS) in the
handout.
Economy – economical designs cost less money and time with lower risks. You need to
select a design that fits your budget and time constraints.
Feasibility – a design that can be properly realised within project constraints. Remember it’s
cheap to have ideas.
Generation techniques:
Team brainstorming
Individual brainstorming
Modelling
Describe the various techniques to help in selecting requirement alternatives. How can
Scoring Matrices be used to help this process?
To evaluate each candidate requirement, you can look at design principles (heuristic
evaluation) and collect data from stakeholder (empirical evaluation). Once each candidate
has been evaluated, the following techniques can be used to help teams select among them.
Pros and Cons – the most simple, list advantages and disadvantages of each. It’s easy and
fast and driven by persuasion.
Crucial experiments – decide based on results of a survey or useability survey. It’s slow and
expensive, but you get clear and objective results.
Multi-dimensional ranking – assign criteria weights, score alternatives and compare
weighted sums.
Scoring matrices can be used to determine the selection criteria and weights (importance)
for each alternative. Each criterion is rated then the score is filled by multiplying the ratings
by its weights. The highest scoring alternative is the one that gets selected.
Explain what a Software Requirements Specification (SRS) is used for. Why do these need to
be developed?
The SRS document provides a solution to all the product design problems in the form of
requirements. It’s the output of the product design process. SRS is necessary in software
products because it’s used to establish the basis of agreement between customers and
suppliers on product functionality
What makes a good requirement? Which of the following are good requirements and why?
What is the difference between basic design principles and constructive design principles?
1. The basic design principles state characteristics that make a design better able to
meet the needs and desires of stakeholders
2. Constructive design principles are about making use of best practice engineering
design characteristics that make designs better
Each of the following heuristics helps make a good module according to some modularity
principles. Identify the principle.
1. Make all attributes of a class protected or private. Information hiding
2. A class should capture exactly one key abstraction. Cohesion
3. Make sure an operation needs all its parameters. Least Privilege
4. Spin off unrelated data into another class. Least Privilege, and Cohesion
5. Minimize the number of classes with which a class collaborates. Coupling
6. Most of the operations in a class should use most of the attributes most of the time.
Least privilege and Cohesion
7. Model a real world whenever possible. (ALL)
8. Do not change the state of an object without going through its public interface.
Information hiding
Each of the following heuristics helps make a good module according to some
implementability and/or aesthetic principles. Identify the principle.
1. Minimize the number of operations in a class. Simplicity
2. Eliminate irrelevant classes from your design. Design with reuse, Simplicity
3. Do not nest control structures more than several levels deep. Simplicity, Design for
reuse
4. Never make a class to do a job that a class in a standard library already does. Design
with reuse
5. Eliminate duplicated code whenever you find it. Simplicity, design for reuse, design
with reuse
6. Provide get and set methods for all attributes in a class that clients might be
interested in, even if they are not all used in the current program. Design for reuse
7. Do not reuse variables to hold different data. Simplicity (clean code)
8. Avoid operations with only a single line of code. Design for reuse
9. Keep operation parameters to five or less. Simplicity
ARCHITECTUREAL STYLES AND APPLICATION
FRAMEWORKS
Explain what activities are part of the Software Architectural Design phase.
If software requirements specification is the problem, then the software architectural design
document is the solution to that problem
Activities include:
Identifying the components of the system and sub-systems
Defining the connectors (interfaces) between these components and sub-systems
The process is:
1. Analyse the SRS
2. Generate or improve upon a candidate architecture
3. Select the architecture for your system
4. If it’s found to be adequate, finalise the architecture for the Software Architecture
Document (SAD)
For each architectural pattern, discuss when they may be used, and their advantages and
disadvantages.
An architectural pattern is a description of good design practice that has been tried and
tested in various environments.
1. Model-View-Controller
Separates presentation and interaction from the system data. The system is
structured into three logical components that interact with each other. The Model
component manages the system data and associated operations on that data. The
View component defines and manages how the data is presented to the user. The
Controller component manages user interaction (e.g., key presses, mouse clicks, etc.)
and passes these interactions to the View and the Model.
Example - The below example shows the architecture of a web-based application
system organized using the MVC pattern.
Use it when: there are multiple ways to view and interact with data. Also used when
the future requirements for interaction and presentation of data are unknown.
Advantages: Allows the data to change independently of its representation and vice
versa. Supports presentation of the same data in different ways, with changes made
in one representation shown in all of them.
Disadvantages: May involve additional code and code complexity when the data
model and interactions are simple.
2. Layered
Organizes the system into layers, with related functionality associated with each layer. A
layer provides services to the layer above it, so the lowest level layers represent core
services that are likely to be used throughout the system.
Example - A layered model of a digital learning system to support learning of all subjects
in schools:
Use when: building new facilities on top of existing systems; when the development is
spread across several teams with each team responsibility for a layer of functionality;
when there is a requirement for multilevel security.
Advantages: Allows replacement of entire layers as long as the interface is maintained.
Redundant facilities (e.g., authentication) can be provided in each layer to increase the
dependability of the system.
Disadvantages: In practice, providing a clean separation between layers is often difficult,
and a high-level layer may have to interact directly with lower-level layers rather than
through the layer immediately below it. Performance can be a problem because
NB: the number of layers is arbitrary but the most common layers of a general
information system are:
UI LAYER (Presentation layer)
UI MANAGEMENT, AUTHE/O (Service layer / Application layer)
BUSINESS LOGIC LAYER (domain layer – app functionality and system utilities)
SYSTEM SUPPORT (data access layer)
3. Repository
All data in a system is managed in a central repository that is accessible to all system
components. Components do not interact directly, only through the repository.
Example - this is an example of an IDE where the components use a repository of system
design information. Each software tool generates information, which is then available
for use by other tools.
This model is suited to applications in which data is generated by one component and
used by another. Examples of this type of system include command and control systems,
management information systems, ComputerAided Design (CAD) systems, and
interactive development environments for software
Use when: you have a system in which large volumes of information are generated that
has to be stored for a long time. You may also use it in data-driven systems where the
inclusion of data in the repository triggers an action or tool.
Advantages: Components can be independent; they do not need to know of the
existence of other components. Changes made by one component can be propagated to
all components. All data can be managed consistently (e.g., backups done at the same
time) as it is all in one place.
Disadvantages: The repository is a single point of failure so problems in the repository
affect the whole system. May be inefficiencies in organizing all communication through
the repository. Distributing the repository across several computers may be difficult.
4. Client-Server
In a client–server architecture, the system is presented as a set of services, with each
service delivered by a separate server. Clients are users of these services and access
servers to make use of them.
Example - this is an example of a film and video/DVD library organized as a client–server
system.
Use it when: data in a shared database has to be accessed from a range of locations.
Because servers can be replicated, may also be used when the load on a system is
variable.
Advantages: The principal advantage of this model is that servers can be distributed
across a network. General functionality (e.g., a printing service) can be available to all
clients and does not need to be implemented by all services.
Disadvantages: Each service is a single point of failure and so is susceptible to denial-of-
service attacks or server failure. Performance may be unpredictable because it depends
on the network as well as the system. Management problems may arise if servers are
owned by different organizations.
Explain why design conflicts might arise when designing an architecture for which both
availability and security requirements are the most important non-functional requiremen
They inherently contradict each other. It is very difficult to have a system that is highly secure and
highly available. E.g. if making multiple servers to support availability, you’d need to ensure that
security is up to scratch on all these servers.
Fundamentally, to provide availability, you need to have (a) replicated components in the
architecture so that in the event of one component failing, you can switch immediately to a
backup component. You also need to have several copies of the data that is being processed.
Security requires minimizing the number of copies of the data and, wherever possible,
adopting an architecture where each component only knows as much as it needs to, to do its
job. This reduces the chance of intruders accessing the data. Therefore, there is a
fundamental architectural conflict between availability (replication, several copies) and
security (specialization, minimal copies). The system architect has to find the best
compromise between these fundamentally opposing requirements.
Suggest a client–server architecture for the below system that shows where functionality is
located.
Hint: simulations are often computationally intensive.
o Your customer wants to develop a system for stock information where dealers
can access information about companies and evaluate various investment
scenarios using a simulation system.
o Each dealer uses this simulation in a different way, according to his or her
experience and the type of stocks in question.
In this case, I would use a fat client model with company information located on a central
server (this is critical information and it's important that it is consistent for all dealers).
Simulations would run on the dealer’s computer as these are used in different ways
depending on the individual dealers. A fat client architecture is required because simulations
require considerable processing and it would place an unacceptable load on the server if
several dealers started simulations at the same time.
Explain the difference between an application framework and a design pattern. What are
the characteristics of a framework?
An application framework can be defined as an integrated set of software artifacts (such as classes,
objects and components) that collaborate to provide a reusable architecture for a family of related
applications. Frameworks provide support for generic features that are likely to be used in all
applications of a similar type.
a. Inversion of control – the overall program’s flow of control is not dictated by the
caller but by the framework itself
b. Extensibility – frameworks can be extended by the use through selective overriding
or by adding specialised user code to provide some desired functionality
c. Non-modifiable framework code – the code of the framework is generally not
supposed to be modified though accepts user-implemented extension. I.e. add code
but don’t modify existing code
A design pattern solves many software design and architectural issues, and they’re pre-defined
designs.
A framework is based on the principle: “don’t call us, we’ll call you” -- you implement some high-level
requirements as specified and let the framework do the rest of the work, calling your
implementations.
A framework is a set of related classes to perform a certain task. Those classes may or may not
implement a certain design pattern. A design pattern is a high-level description of a well-established
design for tackling a problem. A framework is an actual package of code you use to make building
applications easier.
When describing a system, explain why you may have to design the system architecture
before the requirements specification is complete.
The architecture may have to be designed before specifications are written to provide a
means of structuring the specification and developing different subsystem specifications
concurrently, to allow manufacture of hardware by subcontractors and to provide a model
for system costing.
Draw diagrams showing a conceptual view and a process view of the architectures of the
following systems:
o A ticket machine used by passengers at a railway station.
o A computer-controlled video conferencing system that allows video, audio, and
computer data to be visible to several participants at the same time.
o A robot floor-cleaner that is intended to clean relatively clear spaces such as
corridors. The cleaner must be able to sense walls and other obstructions.
Using the UML graphical notation for object classes, design the following object classes,
identifying attributes and operations. Use your own experience to decide on the attributes
and operations that should be associated with these objects.
• a telephone
• a printer for a personal computer
• a personal stereo system
• a bank account
• a library catalogue
Draw a sequence diagram showing the interactions of objects in a group diary system, when
a group of people are arranging a meeting. (Hint, you may need to use Alternative
Fragment)
The above diagram assumes there are 3 participants in the meeting, one of whom is the
meeting organizer. The organizer suggests a ‘window’ in which the meeting should take
place and the participants involved. The group diary communicates with the diaries of the
participants in turn, modifying the window accordingly as their availability is known. So, if
the organizer suggests a window of 18th-19th June, the group diary consults the organizer’s
diary (D1) and finds availability on these days. D2 is then contacted with that availability,
not the original window. If there are no mutually available dates in the window, the system
reports this to the organizer. Otherwise, a date is selected, entered in all diaries and
confirmed to the organizer.
Draw a sequence diagram based on the Java code below. Have your diagram model the
main() operation.
What is a loop fragment in a sequence diagram? What about an alternative fragment? How
do we use these?
A loop fragment notation shows some activity that needs to be repeated until some guard
condition becomes false. It looks like this:
Alternative fragments are used when a choice needs to be made between two or more
messages – it models the ”if else” logic and looks this:
What are the components of advanced state diagrams and how wold we notate these?
Sub-states or Nested States: states can be nested at any level. UML allows you to put
multiple states into a single state to indicate that, when an element is in that state, other
elements inside for it have state as well.
States with a substructure are called composite states. Nested states may have no more
than one initial and one final state. Substate example of a heater:
Action labels:
Entry: execute the associated action-expression upon state entry
Exit: execute the associated action-expression upon state exit
Do: execute upon entry and continue until exit or action completion
What types of advanced state diagrams are there and how do they differ?
http://www.krishnagudi.com/wp-content/uploads/2016/07/Chapter-6.pdf
https://medium.com/@warren2lynch/state-diagram-comprehensive-guide-with-examples-
e08b6d1c70fe
In a room with two doors, it is common to have two switches controlling a single light: one
by each door. Flipping either switch change the light’s state from on to off, or vice versa.
Make a state diagram with a concurrent composite state that includes regions for each
switch and the light illustrating this situation. Your state diagram should track the states of
switches A and B (Up or Down) and the state of the Light (On or Off). The events are all
switch flips.
How might you use a model of a system that already exists? Explain why it is not always
necessary for such a system model to be complete and correct. Would the same be true if
you were developing a model of a new system?
You might create and use a model of a system that already exists for the following reasons:
1. To understand and document the architecture and operation of the existing system.
2. To act as the focus of discussion about possible changes to that system.
3. To inform the re-implementation of the system.
You do not need a complete model unless the intention is to completely document the
operation of the existing system. The aim of the model in such cases is usually to help you
work on parts of the system so only these need to be modelled. Furthermore, if the model
is used as a discussion focus, you are unlikely to be interested in details and so can ignore
parts of the system in the model. This is true, in general, for models of new systems unless a
model-based approach to development is taking place in which case a complete model is
required. The other circumstances where you may need a complete model is when there is a
contractual requirement for such a model to be produced as part of the system
documentation
Develop a sequence diagram showing the interactions involved when a student registers for
a course in a university. Courses may have limited enrolment, so the registration process
must include checks that places are available. Assume that the student accesses an
electronic course catalog to find out about available courses.
Look carefully at how messages and mailboxes are represented in the email system that you
use. Model the object classes that might be used in the system implementation to represent
a mailbox and an e-mail message.
Based on your experience with a bank ATM, draw an activity diagram that models the data
processing involved when a customer withdraws cash from the machine.
DESIGN PATTERNS
Code for design patterns: https://refactoring.guru/design-patterns/abstract-
factory/java/example
Apply the singleton pattern to the below Daytime class. Draw a sequence diagram to model
the new code.
Apply the Factory Method pattern for the following:
1. Create a Plan abstract class and two concrete classes PrepaidPlan and PostpaidPlan that
extends the Plan abstract class.
2. Both PrepaidPlan and PostpaidPlan have the same way to calculateBill(). But their getRate()
is different.
3. Create a PlanFactory class which has a abstract method createPlan(), and two subclasses
PrepaidPlanCreator and PostpaidPlanCreator.
4. Create a GenerateBill class which has a main() method and goes through a list of different
plans and calculate the bill for each plan.
Sketch the code, class diagram and sequence diagram for the above.
Using the Abstract Factory pattern, design the following:
An example of this would be an abstract factory class DocumentCreator that provides interfaces to
create a number of products (e.g. createLetter() and createResume()). The system would have any
number of derived concrete versions of the DocumentCreator class like FancyDocumentCreator or
ModernDocumentCreator, each with a different implementation of createLetter() and
createResume() that would create a corresponding object like FancyLetter or ModernResume. Each
of these products is derived from a simple abstract class like Letter or Resume of which the client is
aware. The client code would get an appropriate instance of the DocumentCreator and call its
factory methods. Each of the resulting objects would be created from the same DocumentCreator
implementation and would share a common theme (they would all be fancy or modern objects). The
client would only need to know how to handle the abstract Letter or Resume class, not the specific
version that it got from the concrete factory.
You have been asked to build a new Campus Security System, based on our Campus Security Data
Object, which tracks current threat alerts (weather, national threat level, and campus threats).
We need you to create an initial application that provides three displays: weather conditions,
national threat colour level, campus threat instructions, all updated real time as the Campus Security
Data Object receives the most recent alerts.
Also, this needs to be an expandable Security System. We want to release an API so other schools
can write their own threat displays and plug them right in.
The Campus Security Data class has 4 key methods: get weatherData(),
Object o = e.getSource();
if (o = fileNewMenuItem)
doFileNewAction();
else if (o = fileOpenMenuItem)
doFileOpenAction();
else if (o = fileOpenRecentMenuItem)
doFileOpenRecentAction();
else if (o = fileSaveMenuItem)
doFileSaveAction();
Apply the Strategy pattern to design a file compression tool which can create either zip or
rar files
Second, design two implementations, one for zip and one for rar
Design a context which provides a way for the client to compress the files. Assume that there is a
default compression strategy and this can be changed by setCompressionStrategy method in the
context.
What are the impacts of code smell on a codebase? Why should we refactor to remove these
smells?
The main purpose of refactoring is to fight technical debt and turn messy code into clean
code. Code that is not easy to understand, that contains duplication, that is unnecessarily
bloated (too many classes, very large classes and methods), and code that just doesn’t pass
all tests is considered unclean and contributes to code smells. Code that is “smelly” is harder
and more expensive to maintain and difficult to make changes to, so it’s important to
refactor to remove the smells.
Identify and describe the refactoring techniques (theres so many of these, maybe ask for like
5)
https://refactoring.guru/refactoring/smells --- this link contains all the smells and the
refactoring techniques to fix them
UI design refers to designing the way that the system receives information from the user,
and how the program presents information to the user. A good UI is generally easy to
understand, meets the needs of its intended users and supports users in the tasks they wish
to undertake.
User familiarity – UI should make use of user-oriented terms and concepts rather
than computer concepts (recreate objects from the real-world to provide context).
E.g. skeuomorphism, folders vs directories.
Consistency – layout, navigation, commands and menus should be consistent across
the entire system.
Minimal surprise – the above helps with this – helps the user become experienced
quickly and reduce their learning curve.
Recoverability – should be some resistance to errors (undo, redo, confirmations of
destructive actions)
User guidance – tutorials, help guides.
User diversity – different options, accessibility etc.)
How is consistency defined in modelling languages? What role do constraints play in this?
A metamodel is used to define consistency in modelling languages by providing the abstract
syntax of a modelling language, which describes how all the concepts (e.g. class,
relationships, objects etc) and relationships existing between concepts that can be used in
that language. Models should conform to metamodels just like you need to conform to a
program language’s syntax.
Constraints go with metamodels to specify conditions that a well-formed model should
satisfy. For example, constraints could acknowledge that you must be consistent between
class and sequence diagrams, or they could describe syntactic and semantic relationships
between model elements.
Describe what Object Constraint Language (OCL) is and what it helps accomplish.
https://st.inf.tu-dresden.de/files/general/OCLByExampleLecture.pdf
OCL is designed to describe constraints (a restriction on one or more values of (part of) an
object-oriented model or system) in UML object models; it allows you to express predicates
that must always be true, that must be true before a method has executed; and that must
be true after a method has executed. These are invariants, preconditions, and
postconditions.
////
context Company inv:
let p = self.manager in
self.employee->includes(p)
////
Context Person inv:
self.bankAccount->size() <= 5