patterns Flashcards

1
Q

What is MVC?

A

MVC is an architectural design pattern that encourages improved application organization through a separation of concerns. It enforces the isolation of business data (Models) from user interfaces (Views), with a third component (Controllers) traditionally managing logic and user-input. The pattern was originally designed by Trygve Reenskaug during his time working on Smalltalk-80 (1979).

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

What is the importance of the MVC (model view controller) pattern to javascript?

A

JavaScript now has a number of frameworks boasting support for MVC (or variations on it, which we refer to as the MV* family), allowing developers to easily add structure to their applications without great effort.

These frameworks include the likes of Backbone, Ember.js and AngularJS.

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

What is the purpose of model in MVC patterns?

A

Models is the data manager for an application. They represent unique forms of data that an application may require so are neither concerned with the user-interface nor presentation layers. When a model changes (e.g when it is updated), it will typically notify its observers (e.g views, a concept we will cover shortly) that a change has occurred so that they may react accordingly.

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

What are views in the MVC design pattern?

A

Views
Views are a visual representation of models that present a filtered view of their current state. Whilst Smalltalk views are about painting and maintaining a bitmap, JavaScript views are about building and maintaining a DOM element. Java views would have been use of Graphical User Interface libraries or JavaServerPages.

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

list some benefits of MVC?

A

Easier overall maintenance. When updates need to be made to the application it is very clear whether the changes are data-centric, meaning changes to models and possibly controllers, or merely visual, meaning changes to views.
Decoupling models and views means that it is significantly more straight-forward to write unit tests for business logic
Duplication of low-level model and controller code (i.e what we may have been using instead) is eliminated across the application
Depending on the size of the application and separation of roles, this modularity allows developers responsible for core logic and developers working on the user-interfaces to work simultaneously

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

What are disadvantages of MVVM?

A

For simpler UIs, MVVM can be overkill
Whilst data-bindings can be declarative and nice to work with, they can be harder to debug than imperative code where we simply set breakpoints
Data-bindings in non-trivial applications can create a lot of book-keeping. We also don’t want to end up in a situation where bindings are heavier than the objects being bound to
In larger applications, it can be more difficult to design the ViewModel up front to get the necessary amount of generalization

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

What are some of the advantages of MVVM?

A

MVVM Facilitates easier parallel development of a UI and the building blocks that power it
Abstracts the View and thus reduces the quantity of business logic (or glue) required in the code behind it
The ViewModel can be easier to unit test than event-driven code
The ViewModel (being more Model than View) can be tested without concerns of UI automation and interaction

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

What is the Adapter Pattern?

A

The Adapter Pattern translates an interface for an object or class into an interface compatible with a specific system.

Adapters basically allow objects or classes to function together which normally couldn’t due to their incompatible interfaces. The adapter translates calls to its interface into calls to the original interface and the code required to achieve this is usually quite minimal.

One example of an adapter we may have used is the jQuery jQuery.fn.css() method

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

What is a facade?

A

The Facade Pattern provides a simpler abstracted interface to a larger (potentially more complex) body of code.

Facades can be frequently found across the jQuery library and provide developers easy access to implementations for handling DOM manipulation, animation and of particular interest, cross-browser Ajax.

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

What is a container pattern?

A

A Container is an object created to hold other objects that are accessed, placed, and maintained with the class methods of the container - queues, sets, lists, vectors, and caches all fit this description. These objects - theelementsof the container - are usually allowed to be of any class and may be of the container class itself. Every Container should also have an associated Iterator type that can be used to iterate through the elements of the container.

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

Explain what the ambassador container pattern means?

A

Ambassador/Proxy pattern
The ambassador pattern is another way to run additional services together with your main application container but it does so through a proxy. The primary goal of an ambassador container is to simplify the access of external services for the main application where the ambassador container acts as a service discovery layer

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

Explain the sidecar pattern in containers|?

A

Sidecar pattern
The sidecar container extends and works with the primary container. This pattern is best used when there is a clear difference between a primary container and any secondary tasks that need to be done for it.

For example, a web server container (a primary application) that needs to have its logs parsed and forwarded to log storage (a secondary task) may use a sidecar container that takes care of the log forwarding. This same sidecar container can also be used in other places in the stack to forward logs for other web servers or even other applications

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

Multi-node application patterns in containers are?

A

In a multi-node pattern, containers are not on a single machine or node, instead these more advanced patterns coordinate communications across multiple nodes. According to Brendan Burns, “modular containers make it easier to build coordinated multi-node distributed applications.”

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

Leader election container pattern.

A

The idea behind this pattern is that the leader election containers can be built once and reused across your application. It addresses the common problem with distributed systems that have replicated processes by having the ability to elect a leader.

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

Work Queue pattern

A

The generic work queue container in this case does the heavy lifting to coordinate the queue. This addresses another common problem in distributed computing, a generic work queue container can be created and reused whenever this capability is required.

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

What is a Scatter/gather pattern?

A

this pattern is common in search engines, where an external client sends an initial request to a “root” or to a “parent” node. The root scatters the request out to a group of servers to perform a set of tasks in parallel and where each shard returns partial data. The root is responsible for gathering the data into a single response for the original request.

17
Q

Example of Multi-node application patterns are

A

Leader election pattern, Work Queue pattern, Scatter/gather patterns.

18
Q

Give example of a single node patterns and explain them.

A

The first is the Sidecar pattern
The sidecar container extends and works with the primary container. This pattern is best used when there is a clear difference between a primary container and any secondary tasks that need to be done for it.
Also there is the Ambassador / Proxy pattern
The ambassador pattern is another way to run additional services together with your main application container but it does so through a proxy.

19
Q

What is the main goal of a ambassador container pattern?

A

An ambassador container’s goal is to simplify the access of external services for the main application where the ambassador container acts as a service discovery layer.

20
Q

Explain the purpose of the Adapter pattern as a single node pattern ?

A

The adapter container pattern generally transforms the output of the primary container into the output that fits the standards across your applications. For example, an adapter container could expose a standardized monitoring interface to your application even though the application does not implement it in a standard way

21
Q

What is IOC?

A

inversion of control (IoC) is a programming principle. IoC inverts the flow of control as compared to traditional control flow. In IoC, custom-written portions of a computer program receive the flow of control from a generic framework. A software architecture with this design inverts control as compared to traditional procedural programming: in traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the framework that calls into the custom, or task-specific, code