Design Patterns (Week 7, part #2) Flashcards

1
Q

What are the separation of concerns in web computing?

A

HTML - structure / organisation of content

CSS - presentation

Javascript - functionally

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

What is ‘separation of concerns’?

A

1) A design principle for separating software code into distinct ‘sections’, such that each section addresses a separate concern.
2) A strategy for handling complexity

  • -> Of the problem
  • -> Of the solution e.g. software code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What can we reuse to connect views and data?

A

models and views

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

What are the different variations on the theme of Model-View-{Bridge}

A

1) Model View Controller (MVC)
2) Model View Adaptor (MVA)
3) Model View Presenter (MVP)
4) Model View ViewModel (MVVM)

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

Define the components of MVC

✨✨✨

A

Model - directly manages data, logic and rules. Expresses behaviour of problem domain

View - output representation of information

Controller - accepts input and converts it to commands for the model or view

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

What is MVVM?

✨✨✨

A

Model-View-ViewModel

ViewModel is an <strong>abstraction of the view, exposing public properties and commands.</strong>

The binder mediates communication between the view and the data binder

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

Draw an annotated diagram of MVC

A

See diagrams doc #3

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

Draw an annotated diagram for MVVM

A

See diagrams doc #4

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

In terms of MVC, if business logic gets complex, where do we put it?

A

In state

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

Explain the observer pattern in terms of the diagram #5

A

Screen = Presentation:
User sees the quantity they entered and the calculated total
–> Specific to the UI
–> Independent of Domain

Session state = Model
Quantity stored in state
Observer watches the quantity and pushes new total to interface
--> Independent of UI
--> Specific to the Domain

Record state = Data

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

What are the PROs of MVC?

✨✨✨

A

+ Multiple views

+ Synchronized views

+ Pluggable views and controllers

+ Exchangeable look and feel

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

What are the CONs of MVC? (5)

✨✨✨

A
  • Complexity
  • Can have lots of updates/notifications
  • Links between controller and view
  • Coupling of controller/view and model
  • Mix of platform-dependent/independent code within controller and view (porting)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Compare MCV and MVP using two diagrams to illustrate the differences

A

See diagram doc #6

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

Explain the difference between MVC and MVP

✨✨✨

A

1) MVC is Model-View-Controller

<strong>view is stateless with not much logic.</strong>

<strong>Renders a representation of model(s)</strong> when called by controller or triggered by model.

<strong>Gets data directly from model.</strong>

2) MVP is Model-View-Presenter

<strong>view</strong> can be <strong>completely isolated from model</strong> and <strong>rendering data from presenter</strong>, or can be a MVC view, or somewhere in between (e.g. view separate from model)

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

Give diagram for MVP

A

See diagram doc #6 & #7

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

What should we use design patterns for?

A

1) use divide and conquer to develop and integrate
2) separate out concerns and make bridges –> 3-teir architecture of browser, server and data store

–> MV* as a design concept

17
Q

Explain the Model component of MVC

A

1) directly manages data, logic and rules.
2) Expresses behaviour of problem domain
3) updates view,
4) Stores data that is retrieved according to commands from the controller and displayed in the view

18
Q

Explain the View in MVC

✨✨✨

A

1) output representation of information

2) Generates new output to the user based on changes in the model.

19
Q

Explain the Controller in MVC

A

1) accepts input and converts it to commands for the model or view
2) handles input,
3) updates model
4) model’s state (e.g., editing a document). It can also send commands to its associated view to change the view’s presentation of the model (e.g., scrolling through a document, movement of document)

20
Q

What are the three key ideas behind MCV?

✨✨✨

A

1) have bridge connection
2) separate model and view
3) use framework to implement bridge

21
Q

What are the components of Model View ViewModel (MVVM)?

A

1) Model
2) View
3) ViewModel
4) Binder

22
Q

Explain the Model of MVVM

✨✨✨

A

1) Either to a domain model, which represents real state content (an object-oriented approach), or to a data access layer, which represents content (a data-centric approach).
2) what to store in DB or have on server

23
Q

Explain the View of MVVM

✨✨✨

A

1) The view is the structure, layout, and appearance of what a user sees on the screen (HTML & CSS)
2) Vue -> JS and templates

24
Q

Explain the ViewModel of MVVM

✨✨✨

A

1) An <strong>abstraction of the view exposing public properties and commands.</strong>

Instead of the controller of the MVC pattern, or the presenter of the MVP pattern, MVVM has a binder.

2) In the ViewModel, the binder mediates communication between the view and the data binder.

The ViewModel has been described as a <strong>state of the data in the model</strong>

3) binding data for rendering
4) subset of view

25
Q

Explain the Binder of MVVM

A

1) Decalarative data and command-binding are implicit in the MVVM pattern.
2) thing Vue.js implements
3) In ViewModel, the binder mediates communication between the view and the data binder.

26
Q

How does MVVM apply to Vue.js?

✨✨✨

A

Technically, Vue.js is focused on the ViewModel layer of the MVVM pattern.

It connects the View and the Model via two way data bindings.

Actual DOM manipulations and output formatting are abstracted away into Directives and Filters