Unit 10 Flashcards

1
Q

What are the main issues addressed by the Layers pattern and what are the main mechanisms used to address them?

A

The main issues addressed by the pattern are achieving low coupling between elements, and separating concerns.

This is realised by organising the system elements in layers, each layer addressing a particular concern, and managing the coupling between layers carefully.

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

How does the adoption of the pattern facilitate reuse and flexibility?

A

The implementation of general services can be separated from that of other parts of the system. Hence services can be potentially reused in other applications, or their implementation replaced while still providing the same basic services.

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

Describe the relationship between the two styles of Layers pattern illustrated in Figure 1.

A

The five-layered version (Figure 1(b)) introduces two mediating layers between the fundamental layers of the three-layered version (Figure 1(a)).

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

What do you think may determine the flavour of the patterns that should be adopted for the architecture of a particular enterprise system?

A

Complexity and flexibility are determining factors.

For instance, if the relationship between the presentation and domain layers is straightforward and can be easily modified and tested, then it might be more efficient to distribute the logic between these two layers rather than introducing a third one.

On the other hand, in a system that allows complex interactions to occur with a large variety of users and where changes are frequent, the introduction of an application layer might allow the logic in the two other layers to be independently modified, tested and validated. A similar argument applies to the technical services layer.

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

What do we mean by software architecture?

A

Software architecture is a high-level abstract description of the structure of a software system – its major parts and how they are interrelated.

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

How does an architectural pattern relate to software architecture?

A

An architectural pattern focuses on particular elementary principles used in software architectures, so that aspects of the way a particular architecture works can be accounted for by reference to architectural patterns.

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

What are the various ingredients that make up a framework?

A

A framework comprises an architecture, together with a component repository that contains components suitable for use within the framework, plus whatever documentation would facilitate the use of the framework.

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

How does a domain model differ from a conceptual model?

A

A domain model addresses a general set of possible problems or requirements,

whilst a conceptual model addresses a specific problem.

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

What is a common business object?

A

A business object is any entity, such as a customer, that occurs in a business application.

A common business object is one that recurs widely and often, and is worth placing in a component repository.

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

How do frameworks help in the reuse of components?

A

Components may not quite fit into a particular application, or can be too general to be useful. A framework only places in the repository those components that do fit and are useful.

The framework will guide the user to the component required, so that general search methods are not required.

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

Discuss how the Application Controller pattern may apply in a layered architecture.

A

The Application Controller pattern fits nicely in a layered architecture, as illustrated in Figure 9.

The controller may sit in the application layer and mediate between presentation and domain objects.

Actor events are translated into system events between the interface and the controller; this may result in a number of messages between the controller and domain objects.

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

Discuss possible advantages of separating presentation from domain logic.

A

The two main advantages of this separation are: first, presentation logic is not affected by changes in the implementation of the business logic; second, business logic can be tested separately from the presentation logic.

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

What sort of business logic will be invoked by the application controller?

A

The application controller will invoke business logic to:

  • locate class instances within the system, by mapping value and object identities;
  • invoke methods on business objects to check operations’ preconditions (the application controller takes the role of the client in the operation contract);
  • delegate the satisfaction of the operations’ postconditions to business objects.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Discuss the differences and similarities between the application controller and the controller in the MVC pattern.

A

The application controller isolates and abstracts business logic from presentation logic, and controls the workflow of a business process.

The MVC controller manages user inputs through a user interface in order to modify business data.

Thus the contexts of their applications are different: a business process versus a user interface.

The main similarity between the two controllers is that they support a separation of concerns: presentation logic from business logic in the case of the application controller; data from the user’s view in the case of the MVC controller.

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

In this question we consider a variant of the heating system described in Subsection 2.2. The system, HomeWarm, is a central heating system for domestic use. It allows the user to set up a target home temperature to be maintained by the system. It also allows the user to set the periods of time, within 24 hours, when the system should be in operation. HomeWarm is made up of the following components.

  • A thermostat, which senses the temperature of the environment and lets the user set the target temperature to be maintained.
  • A boiler/pump, which heats up and circulates the water to the radiators in the house.
  • A control unit, which lets the user set up the periods of operation of the system (start and end times) within 24 hours. The control unit includes a display which indicates to the user the set periods of operation and whether the system is currently in operation.

The HomeWarm system is designed as an object-oriented system based on an MVC framework. The system includes the classes shown in Figure 11.

(See pic)

Thermostat senses the current room temperature and lets the user set the target temperature. Clock keeps track of time for the control unit. ControlUnit allows the user to set the system operation period (start and end times) within 24 hours; when it is operating, if the temperature sensed by the thermostat falls below the target temperature, it activates the boiler. Display shows the current user setting (start and end times), and whether the system is currently in operation. The Observer pattern is applied repeatedly in the design of HomeWarm to achieve the correct system behaviour.

(a) Identify all the relevant subject/observers dependency relations between the HomeWarm classes. Focus on MVC principles and values that change at run-time.
(b) Draw a sequence diagram to illustrate what happens when the system starts operating and senses a temperature below the target one.

A

(a) Display depends on ControlUnit to show whether the control unit is currently in operation and to show the user settings. ControlUnit depends on Thermostat to find out the current room temperature. ControlUnit depends on Clock to start and stop operating.
(b) see pic

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

What is the difference between generalisation (e.g. the superclass in inheritance) and realisation?

A

Generalisation expresses a subtyping relationship between two classes: the subclass is a specialised subtype of its superclass, and instances of the subclass can appear anywhere that instances of the superclass can; the subclass inherits attributes and operations of the superclass.

Realisation is not a subtyping relationship, but instead asserts that a class realises a protocol specified by an interface. The realising class provides an implementation for all the operations that are declared in the interface.

17
Q

Discuss a circumstance under which it would be appropriate to use the Singleton pattern in the hotel reservation example shown in Figure 2.

A

If the software was being designed to manage a single hotel chain, then the class HotelChain would be required to have only one instance. The Singleton pattern could be applied to enforce this condition. Note that the hotel reservation application is almost certainly both distributed and multi-threaded, so implementing Singleton will be more complex than using static methods.

18
Q

Given the document factory example above, how would you modify the class diagram to include a factory for a new type of document? (Hint: None of the interfaces should be modified.)

A

A possible solution is given in Figure 20. A new class representing the factory is included as well as a class representing the new document. Creation requests to the new factory (AnotherDocumentFactory) will result in creation of instances of AnotherDocument.

19
Q

Summarise the steps you need to take to define an enterprise bean.

A

To define an enterprise bean it is sufficient to define one interface and one class.

The interfaces represent the business functions supplied by the bean, which clients need to make use of the bean.

The class represents the implementation of the bean and provides the code for all the methods declared in its interfaces.

20
Q

Java EE applications follow the Layers architectural pattern. Discuss where Java EE containers play a role in a layered architecture.

A

With reference to three-layer architecture, client containers and applet containers work in the presentation layer,

while the EJB container works in the domain layer.

Technologies such as JDBC, which are available in most containers, provide an interface to databases and hence integration with the data source layer.

21
Q

Suggest how you could use Java EE technology to build the client parts of the hotel reservation system.

A

The hotel reservation system will require two types of clients: a web client to allow customers to make reservations online, and a client application to be installed in the hotels.

Therefore, application client and web container technologies will be required.

The business logic may be implemented using enterprise beans within an EJB container, from which the system will be able to integrate with legacy databases.

A possible architectural outline is shown in Figure 31.

Note that in practice, in addition to knowledge of presentation, servlets can contain a significant amount of domain knowledge such as how database tables are interconnected. Because of this, some people put servlets into the domain layer.

22
Q

Draw a table to show the similarities and differences for a service and a component.

A
23
Q

Give a summary of the characteristics of a service in SOA.

A

A service is a self-contained and modular software entity.

It interacts with applications and other services through a loosely coupled, message-based communication model.

It supports interoperability through reliance on communication standards.

It can be found by its consumers through a registry; hence its location is transparent to them.