0% found this document useful (0 votes)
442 views

Revision Questions

Software design is the process of specifying software products to satisfy client needs within constraints. Good design is important today due to software's prevalence and impact. Abstraction and modeling are important in software design. Abstraction focuses on essential data, simplifying problems, while modeling communicates projects through simplified representations. Requirements gathering is important, using techniques like interviews, observations, prototypes. Requirements alternatives are evaluated and selected using techniques like scoring matrices. The Software Requirements Specification document establishes agreement between customers and suppliers on product functionality.

Uploaded by

Andrea Burazor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
442 views

Revision Questions

Software design is the process of specifying software products to satisfy client needs within constraints. Good design is important today due to software's prevalence and impact. Abstraction and modeling are important in software design. Abstraction focuses on essential data, simplifying problems, while modeling communicates projects through simplified representations. Requirements gathering is important, using techniques like interviews, observations, prototypes. Requirements alternatives are evaluated and selected using techniques like scoring matrices. The Software Requirements Specification document establishes agreement between customers and suppliers on product functionality.

Uploaded by

Andrea Burazor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 40

CSIT334 Revision Questions

INTRODUCTION TO SOFTWARE DESIGN

What is Software Design? Discuss the importance of it in today’s world.

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.

Describe the importance of Abstraction and Modelling within software design.

Abstraction refers to suppressing or ignoring some properties in favour of others to help in


focusing on essential/relevant data that doesn’t matter to the problem. Abstraction helps us
focus only on essential data that actually matters to a problem and avoid having to worry
about unnecessary information, simplifying and reducing the complexity of the problem. For
example, writing a patient class for a hospital – you only want to include relevant
information that’s important to human being treated in hospital.

Modelling is a way of representing real-world objects contextually, using only relevant


information that is needed for people to understand. Modelling helps to communicate the
project to other people through simplification/abstraction. This in turn allows more clients
and stakeholders who don’t have a knowledge of software to provide their feedback and
suggestions. It is also important for documentation and helping people understand a
system.

What is the difference between software product vs engineering design?

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.

SOFTWARE PRODUCT DESIGN PROCESS


Identify and describe requirement elicitation techniques. Explain why gathering
requirements is an important part in the software design process.
Interviews – about questioning stakeholders. This is the most important and effective
technique and has a variety of ways to conduct it. It’s effective as you can ask follow on
questions to interviewees, record responses, 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.

Prototype demonstrations – working model of a design/feature exploration. Used for needs


elicitation, needs analysis and requirements generation and refinement.

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.

1. What processes would it be useful to study in determining CAS stakeholder needs?


2. What elicitation techniques would you use to gather needs and desires for the CAS,
and which stakeholders would you use them on?
3. Make a stakeholder-goals list for the CAS product.
4. Make a needs list for the CAS products.

Identify and define the product design principles.


Adequacy – meets stakeholder needs and requirements. E.g. tourist app connects people to
tourists quickly and easily.

Beauty – better looking interfaces are perceived to be better products.

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.

Simplicity – simple designs are often better than over-engineered ones.

Discuss various sources and techniques to generate candidate requirements.


Sources for candidate requirements:
 Users and other stakeholders
 Props and metaphors
 Competitor products
 Similar products

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?

a) The system should be reliable – poor requirement – it can be improved by being


converted into a metric
b) The system should use the Model-View- Controller architecture. -- poor – engineering
decisions shouldn’t be a part of the requirements
c) The system should allow the user to check their bank account balance. -- good –
provides a clear goal and feature that engineers can implement
d) The system should solve all the management problems for the university. -- poor –
unrealistic, ambiguous, doesn’t specify what problem should be solved – remember
it’s one feature for each requirement

What are the SRS quality characteristics?

Developers need to check for:


 Well-formedness – conforms to all rules about stating requirements
 Clarity – clear and easy to understand
 Consistency – a single product can satisfy all the requirements
 Completeness – includes every relevant requirement
 Verifiability – every requirement is verifiable
 Uniformity – the way all the requirements are specified are all consistent
 Feasibility – contains requirements that designers are confident can be satisfied

Stakeholders need to check for:


 Correctness – the SRS specifies a product that satisfies stakeholder needs and
requirements subject to constraints
 Proper requirements prioritisation – requirements are prioritised in accordance to
stakeholder needs
SOFTWARE ENGINEERING DESIGN PROCESS AND
PRINCIPLES
What is the difference between Architectural Design and Detailed Design?
1. Architectural design specifies the main parts or components of a software system
and their responsibilities, properties, interfaces, as well as the relationships and
interactions between these components. Architectural design is a high-level process
2. Detailed design is the second part of the engineering process. This is where we
specify the internal elements of a program’s major parts. We define their structure,
their processing and their relationships. This usually includes defining classes and
algorithms and data structure. It's a low-level design process.

Classify each of the following statements as an architectural or detailed design specification:


1. The find() operation must use a binary search algorithm. Detailed
2. The program must separate the user interface code from the
rest of the code. Architectural
3. The client must complete processing in no more than one second and the server must
complete processing in no more than half a second. Architectural
4. The Register class must maintain clients in a hash table. Detailed
5. All utilities in the graphics library must be thread-safe. Architectural
6. All Car object must register themselves with the Clock object, and the Clock object
will notify the Car objects when a second has passed. Detailed
7. All observers of the Clock class must implement the ClockUser class. Detailed

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

List the basic design principles.


1. Feasibility – if the design can actually be realised then it is acceptable
2. Adequacy – the design that meets the most of the stakeholders needs and desires
(subject to constraints) is the better design
3. Economy – designs that can be built at less cost, in less time, with less risk, are better
4. Changeability – designs that make a software easier to make changes to are
preferable

List the constructive design principles.


1. Modularity – modular designs are better
a. To be modular means for a program to be composed of well-defined,
conceptually simple, and independent, units that communicate through well-
defined interfaces.
b. Modularity supports the following:
i. Small modules: smaller modules are better
ii. Information hiding: each module should hide the details of its internal
structure from other modules
iii. Least privilege: modules should be structured in such a way that they
don’t have access to any unneeded resources
iv. Low Coupling: coupling between modules – being the degree of
connection or dependency between modules – is kept to a minimum
which makes it easier to make changes
v. High cohesion: Cohesion is the degree to which the elements of a
certain module belong together, so it is a measure of how strongly
related each piece of functionality expressed by the source code of a
software module is. The best type of cohesion is functional, where
each of the elements of a module cooperate to achieve a single
function.
vi. Cohesion and coupling: https://www.javatpoint.com/software-
engineering-coupling-and-cohesion
2. Implementability – designs that are easy to implement, change and test are better.
a. Implementability supports:
i. Simplicity – simpler designs are better
ii. Design with reuse – deigns that reuse existing assets are better (using
existing artefacts to build new software products – these artifacts are
known as assets in this context)
1. Examples include using libraries and packages to support your
software rather than reinventing the wheel
iii. Design for reuse – designs that produce reusable assets are better
(reusability and modularity go hand in hand)
3. Aesthetic – promoting beautiful engineering design (clean code, use of appropriate
patterns, code craftsmanship, elegant algorithms etc)

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)

Describe the relationship between non-functional requirements and architecture. How do


they affect each other?
https://www.guru99.com/non-functional-requirement-type-example.html
A non-functional requirement specifies quality and performance attributes of a software
system.
Non-functional requirements are heavily influenced by architectural design. Architectures
have a big influence on quality attributes specified in non-functional requirements.
 The particular style and structure that we choose for a system depends on the non-
functional requirements. E.g. cost, safety, scalability, availability.
The architecture that you should select for your system should depend on the non-functional
requirements such as:
 Performance – localise critical operations within a small number of components and
minimise communications.
 Security – if this is the most important non-functional, you should think about multi-
layered architectures. So that when a request wants to access something, the
request needs to go through multiple layers of security first.
 Availability – you need to think about having redundancies. E.g. have multiple
application server components so if one goes down, you’ll still have backups that can
run.

Discuss the methods to generate architectural designs


1. Determining functional components – this is where we create components that are
responsible for realising collections of funcional and data requirements. We can do
this using a process called functional decomposition.
a. Functional decomposition - this I a process of taking some complex process
and breaking it down into its smaller simpler parts. Think about using an
ATM. This activity could be decomposed into
i. Walk up to atm
ii. Insert bank card
iii. Enter pin
iv. So on...
b. Functional decomposition is beneficial as it means that when we start coding,
we are working on the simplest possible components for our application – so
developing and testing them will be easier too. Obviously, this process s more
costly upfront in terms of an investment in time.
2. Modify an existing architecture – alter the architecture for a similar program
3. Elaborate on an architectural style – use an existing architectural style (a paradigm
of a program or system constituent types and their interactions – like an
architectural pattern) and expand on it to create your architecture

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.

5. Pipe and filter


The processing of the data in a system is organized so that each processing component
(filter) is discrete and carries out one type of data transformation. The data flows (as in a
pipe) from one component to another for processing.
Example – this is an example of a pipe and filter system used for processing invoices.
Use it: in data-processing applications (both batch and transaction-based) where inputs
are processed in separate stages to generate related outputs.
Advantages: Easy to understand and supports transformation reuse. Workflow style
matches the structure of many business processes. Evolution by adding transformations
is straightforward. Can be implemented as either a sequential or concurrent system.
Disadvantages: The format for data transfer has to be agreed between communicating
transformations. Each transformation must parse its input and unparse its output to the
agreed form. This increases system overhead and may mean that it is impossible to reuse
architectural components that use incompatible data structures.

What are the major components of the client-server architecture?


1. A set of servers that offer services to other components. Examples of servers include
print servers that offer printing services, file servers that offer file management
services, and a compile server that offers programming language compilation
services. Servers are software components, and several servers may run on the same
computer.
2. A set of clients that call on the services offered by servers. There will normally be
several instances of a client program executing concurrently on different computers.
3. A network that allows the clients to access these services. Client–server systems are
usually implemented as distributed systems, connected using Internet protocols.

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.

The characteristics are:

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.

What is the fundamental difference between a fat-client and a thin-client approach to


client–server systems architectures?
In a fat-client system, some of the application processing is carried out on the client whereas
in a thin client system only the user interface is displayed on the client and all of the
application processing is carried out on the server. However, modern web browsers are all
javascript enabled which means that code can be downloaded from the web page on the
server and executed within the client browser. This means that some of the functionality of
fat clients can be replicated without the need to install software on the client system.
DETAILED DESIGN MODELS
State machine, sequence, composite QNA:
https://www.uio.no/studier/emner/matnat/ifi/INF5150/h12/old-exams/x5150-2009-
solution-modeling.pdf
Sequence Diagrams: https://www.uml-diagrams.org/sequence-diagrams.html

What are the two types of design models?


Design models can be static or dynamic.
Static models (like UML class diagrams) help design the definition of packages, class names,
attributes and method signatures but do NOT define method bodies
Dynamic models (like UML interaction diagrams – sequence, state, communication) help
design the logic and behaviour of the code or the method bodies.

Draw a sequence diagram documenting the following interaction:


An instance named ga of a Game class is active and it sends an instance of the Dice class
named die a roll() message. The die object holds a reference to an instance of the Random
class called urn, and sends it the message nextInt(6). The result of this message is
incremented by one and returned the die to the Game object. All messages are
synchronous.

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?

https://creately.com/blog/diagrams/sequence-diagram-tutorial/ (GREAT REFERENCE)

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:

Another example of nested state for a phone line:


Entry and Exit Actions: these provide an alternative to showing actions on transitions. If
transitions into a state have to perform the same task then it's easier to attach the action to
the state itself.
Activities / Do actions: activities can be associated with a state. They can be continuous
operations (like displaying a picture) that are only terminated by some other event, or they
can be an operation or series of operations that terminate on their own.
The notation “do: A” indicates that activity A begins on entry to the state and stops
when complete, unless interrupted by an event

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

Concurrent Composite State


 Related states can be grouped together into a single, composite state. Nesting states
is necessary when an activity involves concurrent sub-activities.
 An example of an auction process that has two concurrent sub-states (processing a
bid and authorising a payment limit):

Sequential Composite State


 Sequential composite state models sub-states that are disjoint (not concurrent)
Internal Transitions
State diagrams with internal transitions have some internal actions to execute as a result of
some event, but these internal actions do not lead to state transition (these are the entry,
exit, do)
Draw a state diagram with current composite state for the following:

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

Suppose that a program simulates checkout lines at a supermarket. An instance of a Queue


class that holds instances of Customers simulates each lane. A Checkout Object has 10
Queue objects. Time is simulated by a Clock instance. Every simulated minute, the Clock
notifies the Checkout that time has passed. The Checkout then calls its own addCustomers()
operation. This operation adds new Customer objects to each Queueby generating a random
number between zero and four (using a Random object) and adding that many new
Customer objects to the Queue. It them calls its own processCustomers() operation. This
method removes Customers from each Queue by generating a random number between one
and three (using a Random object) and removing that number of Customers form the Queue
an destroying them. It also records statistics about the simulation for later display. Design
this interaction and document it using a class diagram and one or more sequence diagrams.

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

What is the difference between abstract factory and factory patterns?


Both of these are patterns for creating objects, and they both hide the details of the
implementation/creation of the objects from the outside classes so we see only the
interfaces. For the factory methods, we create only one single object. On the other hand,
with abstract factory patterns we create multiple products. Another difference is in factory
patterns, the methods to create the objects are delegated to the subclass. In abstract, it’s
delegated to the concrete classes. Abstract thus provides an extra layer of abstraction.

Factory Abstract Factory


Create one product Create families of related or dependent
products
Depends on inheritance to decide which We have classes dedicated to creating
product should be created (class based and objects of a certain family which can be
relies on a subclass to handle desired passed to the client for use. This is a
subclass instantiation) composition rather than inheritance
relationship.
FactoryMethod is just a single method AbstractFactory is a whole class is
responsible for creating objects responsible for creating families of objects
Abstracts the wat objects are created Abstracts the way factories are created
which in turn abstract the way objects are
created (one more level of abstraction)

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.

Use the Observer pattern to design the following:

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(),

getNationalAlert(), getCampusAlert(), and alertsChanged()


Redesign the following code using the Command pattern

public void actionPerformed(ActionEvente)

Object o = e.getSource();

if (o = fileNewMenuItem)

doFileNewAction();

else if (o = fileOpenMenuItem)

doFileOpenAction();

else if (o = fileOpenRecentMenuItem)

doFileOpenRecentAction();

else if (o = fileSaveMenuItem)

doFileSaveAction();

// and more ...

Apply the Strategy pattern to design a file compression tool which can create either zip or
rar files

First, design a compression strategy interface

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.

Demo how this is used.


NEED AN ADAPTER PATTERN EXAMPLE

What is an engineering design pattern and why would we use one?


Design patterns are typical solutions to commonly occurring problems in software design.
They are like pre-made blueprints that you can customize to solve a recurring design
problem in your code.
You can’t just find a pattern and copy it into your program, the way you can with off-the-
shelf functions or libraries. The pattern is not a specific piece of code, but a general concept
for solving a particular problem. You can follow the pattern details and implement a solution
that suits the realities of your own program.

ANTIPATTERNS AND SOFTWARE REFACTORING


What is an anti-pattern? How does it contribute to the code smell phenomenon?

Antipatterns describe a solution to a problem that generates negative consequences – ie it


is commonly used but is ineffective and counterproductive in practice
Design or code that is commonly seen and is decidedly bad is known as a code smell
Code smells are symptoms in the source code that could potentially (*not always) indicate
deeper problems

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

USER INTERFACE DESIGN


Explain the importance of having a well-defined user interface for your product.

A well-defined UI is paramount to determining how your product will be received by users,


because systems are often judged by their interfaces and not their functionality. Further, a
poorly designed interface may introduce catastrophic errors in which the main goal of the
system cannot be fulfilled by users leading to frustration and abandonment.

What is UI design about and what makes a good UI design?

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.

Identify and explain the UI design principles

 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.)

QUALITY ASSURANCE FOR SOFTWARE DESIGN


Explain how consistent design models help to provide clear system representations for both
human and computer interpretation.
A model is a description of a system using a well-defined modelling language (like UML).
Having a clear system representation allows for consistency when designers model up a
system. For example, UML class diagrams all look the same and are easily recognisable by
developers and stakeholders, helping to portray the system so stakeholders can provide
feedback, and so developers know exactly what to create. For computers, there are features
in IDEs that automatically convert UML diagrams into source code, provided that the
diagrams follow metamodels and constraints.

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.

Explain what each of the following OCL statement means:


http://www.inf.ed.ac.uk/teaching/courses/seoc/2014_2015/tutorials/tutorialWk9tutors.pdf
ANSWERS ^^^

1. People who are married must be over the age of 15


2. The number of Employees is always equal to the size of the Employee array
3. To resolve the income function, the date passed must be greater than the birthdate of the
person object in question. Then, if the age of the Person is < 18 then the income will be <
100, else it will be < 200.
////
context Person inv:
firstName.size() < 20

////
context Company inv:
let p = self.manager in
self.employee->includes(p)

context Person inv:


self.managedCompanies->forAll (c | self.employer->includes(c));

////
Context Person inv:
self.bankAccount->size() <= 5

You might also like