03 Flashcards Preview

My TMA derived Questions > 03 > Flashcards

Flashcards in 03 Deck (23):
1

Identify two architecture styles in the following scenario

"The boat club operates a private, social-networking site called 'Grapevine' that its members can join. Members can also sign up to receive a daily email summary of activity by people they are following on this site."

• Client-server: the members using a web browser are the clients and they connect to the server which offers the website functionality

• Notification: also known as publish-subscribe at an architectural level. The members registering to receive daily e-mail summary are the subscribers because they register to receive updates. The publishers are the people the subscribers are following because their activity is sent to the subscribers.

2

When it comes to reuse, what is the difference between architectural styles and framework?

Architectural styles represents basic forms of architecture we can reuse in the design
of new systems. Frameworks provide complete architectures designed for reuse.

3

What design pattern aims to do? Where are they used?

Each pattern solves a recognisable problem that crops up over and over again.

Usually design patterns only apply in an object-oriented setting and involve just a few software classes and the relationships between them.

4

What's an interface?

An interface is indicated by using the UML stereotype «interface». An interface is not a class and doesn’t define
any implementation for its operations, only their signatures

5

Suppose a commercial products being considered is a Reservations
component, which offers the following services.

* reserve a boat, given the member, boat type, date and time, and return a reservation number
* get the reservation corresponding to a given reservation number

* cancel a given reservation.


Use the UML notation for specifying the provided interfaces of components to give
the interface specifications of this component. We are asking you to specify the interfaces, not the components themselves.You will need to invent suitable names for the operations concerned..

View printed answer 2

6

What is the difference between generalisation and realisation?

Generalisation expresses a sub-typing relationship between two classes. The subclass is a specialised subtype of its superclass and inherits the attributes
and operations defined by the superclass.

Realisation is not a sub-typing relationship but instead expresses the fact that a class provides an implementation for all the operations specified by
an interface.

View printed answer 3

7

Design pattern: Adapter

Purpose
How it works – a description of the solution
When to use it
Example of use

Name. Adapter.

Purpose. Allows a client to use a class that has a different interface from the one the client is expecting.

How it works. An Adapter class is introduced that provides the client with the interface it is expecting but forwards client requests to an object of the class with the incompatible interface

When to use it. When you want to use a class with a client that is expecting a different interface from the one the class provides.

Example. Legacy software may need to be integrated with a newer system that uses a different interface.

8

Design pattern: Model-view-controller pattern (MVC)

Purpose
How it works – a description of the solution
When to use it
Example of use

Can be regarded as an architectural style as well
as a design pattern. (MVC) pattern can represent
the overall architecture of some applications, but it can also be a pattern applied to designing just part of a system.

Name. Model-view-controller (MVC).

Purpose. Splits user interface interaction into three distinct roles: the model of the domain, the view representing that domain, and the controller of changes to the domain.

How it works: It identifies three roles: model, view and controller.

When to use it. When you have a user interface that you want kept separate from the model. Advantages:
*The user interface is not affected by changes in the implementation
of the business logic.
*The same domain logic can be used with different user interfaces.
*The business logic can be tested separately from the interface logic.

Example.a chart (the view) which is a graphical representation of the state of an underlying model. If the user changes a value in the table (the controller) the state of the model changes and the change is propagated to the chart

9

Design pattern: Observer Pattern

Purpose
How it works – a description of the solution
When to use it
Example of use

Name. Observer (also sometimes known as publish–subscribe like the notification architectural style which it resembles).

Purpose. Mechanism needed to ensure that when the
state of an object changes related objects are updated to keep them in step while keeping coupling between them be loose so you have the flexibility to vary them independently.

How it works.
One object has the role of the subject (or publisher) and one or more other objects the role of observers (or subscribers). The observers register themselves with the subject and if the state of the subject changes the observers are notified and can then update themselves.

When to use it. When different parts of a system have to be kept in step with one another without being too tightly coupled.


Example. As noted, the relationship between the view and the model in an MVC design can be realised by applying the observer pattern. The view registers with the model and is notified every time the model’s state changes, allowing it to update itself to reflect the change.

10

When dealing with design patterns, there are three categories: creational, structural and behavioural. Explain and give example.

Creational patterns: deals with ways of creating objects
independently of the clients that will use them. Example: factory and singleton

Structural patterns,: deals with relationships among classes and objects. Example: adapter

Behavioural patterns, which deal with how objects communicate and interact. Example: observer

11

In your own words describe briefly what is meant by a framework, in the context of software development.

Instead of writing code from scratch for a new system, a framework can be used to save time and resources.

Made of a reusable architecture and several components that can be inserted into the reusable architecture to adapt to different situations, it’s also useful that a framework provides some type of documentation

12

How could the Template Method pattern be used as part of a framework?(

We could define a Template class that will be part of the reusable architecture and the subclasses would be the set of components that are added to the reusable structure. To re-use or customize the framework, a developer would use these components (the subclasses), overriding the primitive operations to adapt the needs of a specific system.

13

Discuss any similarities and differences between the Template Method pattern and the pipe-and-filter architectural pattern

In both cases there are several small steps that have to be executed in order to achieve something

In both cases, the individual steps/path will change depending on what was requested.

Pipe-and-filter components stream data and pass the results to the next component, template method has a more centralized approach with one class calling subclasses hence orchestrating the flow of the program

Pipe-and-filter Is very versatile and can be applied to any system. Template method uses an inheritance approach: the subclass inherits from the superclass and override these, this makes Template method suitable only for object-oriented systems.

14

In SOA, Services can also be classified as either task-oriented or entity-oriented services.

Task-oriented services are related to business activities (business processes), whereas entity-oriented services are related to business entities (business objects)

15

Suggest three examples of functions that could be implemented as services, saying
whether each is task- or entity-oriented, and classifying it as a utility, business or
coordination service.

.

16

Performance and Usability scenarios are expressed in a six-part model. The parts are:

source
stimulus
artefact
environment
response
response measure

Explain each

Source is a human actor, another system, or anything else that can generate a stimulus. 'external', 'internal'

Stimulus is any kind of event or request

Artefact is what will respond to the stimulus. Often 'system'

Environment specifies the conditions which the scenario assumes the artefact will be operating under. 'normal operation' and 'overload'

Response is what happens as a result of the artefact receiving the stimulus

Response measure is an objective yardstick by which we can test if the requirement has been met.

17

There are 6 performance scenario: latency, deadline, throughput, jitter, miss rate, data loss

Latency: time taken to process a stimulus, for example how long does a search engine take to respond to a query?

Jitter is the amount of variation in latency:for example, are some responses very quick while others take much longer?

Throughput: the number of events dealt with in a given time.


Miss rate measures the proportion of events that are not responded to

Data loss measures how much data is lost because the system fails to record it.

Deadline: not in the book

18

Assuming DbC, explain how to design black-box tests for this operation

I’d use a mix of partitioning and boundary testing so I’d be testing data at the boundaries between each partition of the input data space. I’d not check null instances because on DbC, the test methods are only made for values that are valid according to the method’s preconditions. I assume it’s the client’s responsibility to filter out invalid results.

19

Describe an assertion, what is an assertion used for?

//Little comment explaining assertion
Assert *boolean expressions*

Example
//check the surname and initials of this member and otherMember are not null

Assert this.secondName != null &&
otherMember.secondName != null &&
this.initials != null &&
otherMember.initials != null;

assertions are used to tested pre and post conditions are true

20

Developmental testing occurs at three
different levels:

– unit testing
– integration testing
– system testing.

Briefly explain what each of these forms of testing is concerned with

– unit testing: testing performed on classes, it focuses on systematically testing methods using test cases. in OO unit is the class hence the name.


– integration testing: tests a combination of units (partial build of the software system)

– system testing: checks that the entire system as a whole performs in accordance to some previous wrote testable requirements.

21

Calculate the cyclomatic-complexity metric of the following method, briefly showing
your working.

public static int findSecondBiggestItem
(int[] array) {
int biggest = array[0];
for (int item : array) {
if (item > biggest) {
biggest = item;
}
}
int secondBiggest = array[0];
for (int item : array) {
if (item secondBiggest ) {
secondBiggest = item;
}
}
return secondBiggest;

}

The method has cyclomatic-complexity of 6. My workings are below

Line number Cyclomatic-complexity
1 1 (starts at one)
3 2 (for loop)
4 3 (if statement)
7 4 (for loop)
8 5, 6 (if statement, &&)

22

Explain the importance of LCOM4 and how to draw it.

LCOM4 measures lack of cohesion, high cohesion is a quality classes should
possess, so this is a key metric.

1- Methods are represented by a square
2- Classes instance variable by a circle
Draw lines:
a) from each method to each of the instance variable it uses
b) from each method to each of the other methods it calls.

LCOM4 is the number of parts the graph falls into, its 'number of connected components'
View printed material for example

23

What cyclomatic complexity measures and what LCOM4 measures? Why is important to measure them?

Cyclomatic-complexity measures how complex a method is, the higher the complexity, the more likely there will be errors in the method body. . Lower complexity means the code will be simpler to read, understand and maintain as well as being less likely to have errors



LCOM4 helps measure how cohesive a class is. Cohesion measures if the activities of a module are closely related to another. High cohesion is desirable because it groups together a set of closely related activities that share a common purpose, excluding unrelated ones. Functions that are closely related could get changed together as a unit