Unit 9 - Architecture, patterns and reuse Flashcards

1
Q

What is software architecture?

A

The software architecture of a program or computing system is the structure or structures of the system, which comprise software elements, the externally visible properties of those elements, and the relationships among them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A popular architecture for websites is the LAMP stack. What does this refer to?

A

. Linux
. Apache webserver
. MySQL database
. PHP (or Python or Perl – all programming languages).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Suggest a reason why choosing the architecture very late on might be a bad idea.

A

Choosing the architecture at a very late stage suffers from the risks of the waterfall approach. By then many other design decisions will have been taken and it will be too late to change them, even if they force us to adopt an architecture that is less than ideal.

An analogy could be with building a house. Would anyone dream of starting construction without an architectural design for the building?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are four characteristics of ASRs (architecturally significant requirements)

A

. Quality attributes are non-functional requirements such as security, reliability, availability, usability, maintainability, portability and so on that you have met in earlier units.

. Core features are described by Chen et al as ‘the problem the software is trying to solve’. For example, an online chat application is intended to allow participants in different locations to exchange text messages. To do this a network of some sort is essential, which immediately has implications for the architecture.

. Constraints. All requirements can be described as constraints, but here the authors mean requirements such as technical constraints – for example, the client may have specified a particular programming language – or non-technical constraints such as budget or time.

. Application environment. This is the environment in which the system will run. For example, a navigation app will need GPS connectivity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 4+1 model architectural views?

A

. The logical (or functional) view describes the system’s main functional elements and their interactions – broadly, the services the system must provide to users.

. The process view describes the set of independently executing processes that will exist at run-time and the communication between them.

. The physical (or deployment) view describes how the system will be deployed to an operating environment in terms of the physical computers and networks on which the system will run.

. The development view describes how the software will be split into subsystems that can be allocated to teams of developers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe the three architectural views. Each view tends to emphasise issues that matter to various stakeholders.

A

. The logical view describes the main functional elements and how they interact, and assumes that these correspond to subsystems that can be
allocated to teams of developers.

. The process view describes the independent processes executing at runtime and the communication between them, regarding the processes as
components and the communication as taking place via connectors.

. The deployment view describes how the system will be deployed to an operating environment, the physical computers and networks on which the system will run. It is important to us because deployment decisions will have a major impact on quality attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Imagine a large distance-learning university requires a system for the electronic submission of student assignments, their subsequent marking and
return, and the recording of results.

Think of some stakeholder groups and for each group suggest one or more concerns that might influence the architecture.

A

. Students and teaching staff will be concerned with core functionality, usability, availability and performance – core features and quality attributes.

. The examinations section will be particularly concerned with security – quality attributes.

. The finance department will be concerned with the cost – constraints.

. Management will be concerned with the cost, when the system will be delivered and its effectiveness – constraints, core features.

. Designers will be concerned with how the system can be partitioned, what the run-time elements will be and where they will be deployed – the application environment.

. Programmers will be concerned with the core functionality represented in the design, how easily the design can be implemented in code and what
language(s) will be used – core features, quality attributes, constraints.

. Testers will be concerned with whether the system is easy to test – quality attributes.

. The IT department will be concerned with the operating environment and how easy the system is to run – application environment.

. Developers responsible for maintaining the system will be concerned with how easy the system is to modify – quality attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Think of some reasons why reuse is desirable.

A

. It avoids duplication of effort and reinventing already existing solutions, which saves resources.

. It promotes reliability because developers can use tried and trusted solutions.

. It speeds up development because developers can take existing solutions without starting from the beginning every time.

. It is a mechanism for spreading good practice among the software development community and familiarising practitioners with tried and tested solutions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Other than software elements, what else can be involved in reuse?

A

. knowledge in the elicitation of requirements, known as requirements patterns

. ways of solving conceptual analysis problems, known as analysis patterns

. architecture – this may just involve reusing a structural idea or it may go further and allow the creation of a series of systems by taking the same basic architecture and modifying the detailed code

. ways of solving particular problems of design and implementation, known as design patterns

. ways of doing things in a particular language – these are small units of reuse known as idioms.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are some common architectural styles?

A
Client–server
Call-return
Layered
Peer-to-peer
Data flow
Data-centred
Independent components
Service-oriented
Notification
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe the client-server style

A

Client–server style is probably the best known of all architectural styles. One component (the server) provides a service to the other component (the
client). The server waits for requests from clients, processes each one as it as received, and returns a response to the client.

A familiar example of the client–server style is a request sent from a web browser to a web server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Describe the call-return style

A

In a call-return style a component (the caller) makes a procedure call to another component (often known as the callee) and waits for the call to return.

In traditional software a main program calls a subprogram and then waits for a reply. In object-oriented programming the call takes the form of a method invocation by one object on another by the sending of a message.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe the layered style

A

The essence of a layered style is that the system is structured as a series of layers that are visualised as stacked on top of another. Each layer uses services provided by the layers below (usually just by the layer immediately below). It also supplies services to the layer above.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe the peer-to-peer style

A

The peer-to-peer style resembles the client–server style except that all the components are both clients and servers and any component can request
services from any other component.

An example of peer-to-peer is a streaming music service, where listeners generally get streamed tracks from the nearest peer that can be located by sending a request that hops from one peer to another until the desired track is located

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe the data-flow style

A

The data-flow style components are objects or
small independent subprograms (filters) that process a stream of data and pass the results on to other components for further processing. Communication is
unidirectional and uses fixed channels. Each filter has no knowledge of other filters upstream or downstream, but simply accepts the data, processes it and passes it on. The connectors are services, provided by the operating environment, that ‘pipe’ data from one filter to another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Describe the data-centred style

A

In the data-centred style there is a data provider that is a centralised store of persistent data. The structure of the data, the types of items and their relationships are stable and change rarely or not at all. There are many clients who are data consumers. Items can be created, queried, updated and destroyed on request.

There are two forms of the data-centred style:
. If communication is always initiated by clients and the store simply responds to requests it is called database or repository. Typically the components are a database server and clients that access it. The connectors are database queries made via a special database connection. A database holding personnel records is an example of this form, with authorised users being able to log on and submit queries.

. A variant in which the store is active and informs users of changes, so that communication may be initiated from either end, is termed a blackboard.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Describe the independent components style

A

In the independent components style, components execute concurrently and are decoupled as far as possible, but can communicate by messages that
allow them to exchange data or coordinate their operations. The connectors are the message exchange protocols, which are normally asynchronous – that
is, the sender can continue without waiting for an answer from the other component.

18
Q

Describe the service-oriented style

A

In the service-oriented style there are two kinds of component, the consumers and the providers – a set of service providers makes services available to a set of service consumers. Consumers can combine services in order to carry out the business processes they require.

The connectors are the requests and responses sent between consumers and providers, using standard communication protocols. In some cases communication is facilitated by a virtual communication channel called an enterprise service bus (ESB), which supports features such as service look-up and routing of service requests.

19
Q

Describe the notification style

A

In the notification style the two kinds of components are observers and subjects. Observers can register themselves with a subject in order to be kept
notified whenever some particular event happens at the subject’s end.

At an architectural level this style is usually referred to as publish–subscribe. Subscribers register to receive updates (often messages) whenever a publisher posts a new item, for example an RSS feed where
anyone who signs up to the feed receives news updates as they become available. Notification also appears at a more detailed design level. In subsection 5.5 we will discuss a form of publish–subscribe that deals with objects rather than distributed components and is known as the Observer design pattern.

In publish–subscribe there tend to be many subscribers for each publisher.

20
Q

What is a framework?

A

Very often a system will have an architecture very similar to that of systems developed in the past. It may be possible to reuse a large part of the architecture, along with any code the systems have in common. Segments of architecture and code that can be reused in this way are usually called frameworks.

21
Q

Describe the product-line process

A

A software product line is essentially a domain-specific framework. Building and using a software product line follows a series of stages.

1 Product-line initiation: the first stage is to recognise that a series of related software systems do not differ much from each other. This leads to domain analysis.

2 Domain analysis: existing systems in the domain are examined and domain experts are consulted. The area in which the product line will operate is thoroughly analysed to obtain the general customer needs and
the terminology normally used, leading on to general models of data and process, which are in effect the conceptual class diagram and use cases.

3 Architecture specification: further analysis leads to the architecture for the product line. There may be several such reference architectures produced.
These are further elaborations of the domain model that add detail, particularly about the prospective implementation, but still keeping flexibility in mind.

4 Component collection: in the same way as a framework, each of the reference architectures will be accompanied by a repository of components that can be used with it, together with the associated
documentation.

For each particular product a further four
stages are needed.

5 Specific-requirements capture: specific requirements for the new product are captured as specialisations and extensions of the domain model developed in Stage 2.

6 Architecture specialisation: a reference architecture is selected on the basis of the specific requirements. Changes are made to accommodate the specialisations and extensions of the domain model corresponding to the new requirements.

7 Component selection and specialisation: the product that meets the new requirements is then built, selecting components from the repository where these exist and adapting them as necessary. If there is nothing appropriate in the repository, a new component may be
built by those managing the repository for the product line. Alternatively if a component is too specialised to be reusable in other applications it may be simply be written as a one-off. Some ‘glue code’ that adapts new components to the framework may also need developing.

8 Integration and release: finally the components must be integrated into the architecture – a relatively easy process if the architecture has been well designed.

22
Q

What are the various ingredients that make up a framework?

A

A framework consists of an architecture, a small amount of software for the framework, a set of components suitable for use within the framework
and the documentation needed to make use of the framework.

23
Q

List the various forms of reuse discussed in Section 4 and say briefly what is reused in each case.

A

Architectural styles reuse expertise in large-scale architectural design – the types of component used and the patterns of interaction between them.

Frameworks reuse a particular architecture and a set of software components suitable for use within it.

Product lines reuse reference architectures, software components and expertise about the variations needed to fulfil customer requirements.

24
Q

What is the difference between generalisation and realisation?

A
Generalisation expresses a subtyping 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 subtyping relationship but instead expresses the fact that a class provides an implementation for all the operations specified by
an interface.
25
Q

The book, Design Patterns: Elements

of Reusable Object-Oriented Software, describes patterns in to which three categories?

A

. creational patterns, which deal with ways of creating objects independently of the clients that will use them

. structural patterns, which deal with relationships among classes and objects

. behavioural patterns, which deal with how objects communicate and interact.

26
Q

List five very common design/architectural patterns.

A

. Adapter

. Observer (touched on in the discussion of architectural styles), which is a behavioural pattern

. Factory, which is a creational pattern

. Singleton, another creational pattern often associated with Factory.

. MVC (Model View Controller)

27
Q

What are the shortened template headings for documenting design patterns?

A
. Name
. Purpose (also called intent)
. What problem does it aim to solve?
. How it works – a description of the solution
. When to use it
. Example of use.
28
Q

Describe the Adapter pattern

A

. 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 (the Adaptee). The interface the client is expecting is called the Target.

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

29
Q

Describe the MVC pattern

A

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

◦ The first is the model, corresponding to an object with some information about the domain. The model contains data and behaviour and is not directly accessible to the user. If we consider MVC as a layered architecture the model resides in the application
domain (or business) layer.

◦ The view is the representation of the model in the user interface: it displays the output from the system and is what the user perceives of the model’s state. Both the viewer and the controller reside in the presentation layer, the layer responsible for user dialogue aspects.

◦ The controller handles all user inputs that affect the model. The controller also resides in the presentation layer.

◦ User inputs to the controller cause changes to the model’s state, which in turn are reflected in the view

◦ Although the view and the controller are distinct roles, it is important to understand that they are not always represented by different objects. For example, a tick box shows the status of some setting, making it part of the view, but it also lets the user change the setting, making it also part of the controller.

◦ This tight integration is typical of many frameworks used for building user interfaces.

. When to use it. When you have a user interface that you want kept separate from the model. The advantages of this include the following.

◦ Separation of concerns. When designing a model you focus on business objects and processes. When designing an interface you are concerned with user interaction.

◦ Facilitating testing. User interfaces are notoriously hard to test because users can perform so many different sequences of actions, and such testing is usually done manually. Code implementing business logic is easier to test and tests can be automated. Keeping the model separate means that you can take advantage of the relative ease of testing.

◦ Flexibility. Multiple interfaces may be developed for the same model, allowing the design to cater for different types of users and different contexts of use.

30
Q

Discuss possible advantages of separating the user interface from the domain logic.

A

These are the main 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.

31
Q

Describe the Observer pattern

A

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

. Purpose. When partitioning a system into individual classes you want the coupling between them to be loose so you have the flexibility to vary them independently. But a mechanism is needed to ensure that when the state of an object changes related objects are updated to keep them in step.

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

◦ There are two extreme variants of this pattern. In the push model the subject sends the observers detailed information about the change that has occurred. In the pull model the subject simply notifies the observers that there has been a change and it is the responsibility of the observers to find out the details they need to
update themselves.

◦ The Subject and the Observer are interfaces that are implemented by the corresponding concrete classes.

◦ When the state of the subject changes the observer is sent an update() message. The implementation of the update() operation in the ConcreteObserver is then responsible for taking appropriate action to update the Observer.

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

32
Q

Consider the design of a new car park. The car park will have two barriers, one at the entry and one at the exit. The clients for whom the car park is being designed want a software system for monitoring and
displaying how many free spaces are available at any given moment.

The software will have components corresponding to the entry, the exit, a monitor that keeps track of the free spaces, and the display. When a car enters or leaves a signal is sent to the monitor. The display has to be kept in step with the number of free places.

(a) Briefly discuss the proposed system in terms of the MVC pattern.
(b) What examples of the Observer pattern can you identify in this application?
(c) Suppose a software development company specialising in systems for car parks decides to set up a product line. Outline very briefly what steps would be involved.

A

(a) The model is the monitor that keeps track of the free spaces. The view is the display. The controller is the software at the entry and exit that sends signals to the monitor.
(b) There are two examples of the Observer pattern. The software at the entry and exit sends notifications to the monitor, which updates its count of free spaces. When the count changes the display must be notified and will then need to ask the monitor for the new count so that it can update itself.
(c) From the question a product line has already been identified. The next steps are:

◦ examine existing systems – talk to developers and domain experts and analyse what the general user will need, generate a domain model

◦ from the domain model produce one or more reference architectures

◦ generate and document a repository of components that can be used with the reference architectures.

33
Q

Describe the (creational) Singleton pattern

A

The Singleton pattern is used where there should only be one instance of a class. An example would be the strategy of implementing use cases by having all messages from the user interface sent to a single object that is an instance of a central class. Having more than one instance of this class at once might cause problems, for example they might interfere with one another. It’s similar to the idea that a company should only have one chief executive.

. Name. Singleton.
. Purpose. In many cases only a single instance of a class is required and allowing creation of more than one instance would compromise the design of the system.
. How it works.

◦ The Singleton class provides no public operation for creating instances. Instead it defines a public operation getInstance() that lets clients access the unique instance of the class.

◦ One way to implement this is shown in Figure 34. The «singleton» stereotype denotes a Singleton class. Singleton is responsible for creating its own unique instance and no other class should be able to create an instance, so the create() operation is private.

. When to use it. When there must be only one instance of a class. Often this is associated with some global resource that other classes need access to.

. Example. The application of the singleton pattern to
the design of a media manager in a multimedia application. There should be only one instance of the manager, which is created by the MediaManager class itself the first time a client accesses the manager.
This strategy of creation on demand is called lazy instantiation.

34
Q

Where in the hotel system might we use a singleton?

A

We could use a singleton instance of HotelChain as a system object that all messages from the user interface are sent to.

35
Q

What is the factory pattern?

A

A factory is a specialised object for creating and initialising objects needed by clients. The name is taken from real-life factories, which are facilities dedicated to manufacturing products required by their clients. In the design pattern the object the factory produces is called the product.

36
Q

Describe the (creational) Factory pattern

A

. Name. Factory.

. Purpose. If the creation and initialisation of an object is complex and liable to change, making clients responsible for the task introduces an undesirable level of coupling. Encapsulating the creation in a dedicated
factory class hides the details from the client and reduces the coupling.

. How it works.

◦ The client has a dependency, shown by a dashed line, on the factory for the creation of the product, and the factory depends on the Product class to create one
of its instances. The UML stereotype «create» indicates that the dependency between Factory and Product is at object creation. This expresses the fact that the factory must know what class to instantiate.

◦ The factory is often a singleton. Having a single
instance and making it available through a system-wide access point makes it possible for all clients that require the product to use the same factory and avoid duplicated code.

. When to use it. Whenever object creation and initialisation is complex or depends on information that clients may not know or is likely to change.

. Example. Many applications need to use a database management system (DBMS) for storage. A DBMS is an independent program that applications communicate with using a particular protocol. A suitable object can handle the communications but needs to be created and configured correctly for the DBMS concerned. A connection factory can provide the required object without the client application needing to know any details.

37
Q

Suggest some quality requirements that the Factory pattern might help satisfy.

A

The ones we thought of were maintainability and portability (and flexibility if it is counted as distinct from maintainability). You may have come up with others.

38
Q

Describe the Factory method pattern

A

. Name. Factory method.

. Purpose. Sometimes a client requires a factory for a product without knowing the actual class of the product, only its interface.

. How it works.
◦ The client is not aware of the actual class of the factory or the product, and interacts with them only via the interfaces. At run time the appropriate class for the factory will be decided in some way, for example from a configuration file or from a system setting, and the concrete factory instantiated. The factory will then
create a product of the required class, without the client needing to know what that class is.

. When to use it. When the decision about what concrete product to create needs to be deferred.

. Example. Consider a framework for document generation, in which applications can define application-specific documents that can be
manipulated by an editor.

39
Q

What category type is the Adapter pattern?

A

Structural

40
Q

What category type is the Observer pattern?

A

Behavioural

41
Q

What category type are the Singleton and Factory patterns?

A

Creational