03 Flashcards
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.
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.
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.
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
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
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
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.
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
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.
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
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
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.
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.
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)
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.
.