Coding 101

Oct 9th 2014

Coding 101 38

C#: Building an App 2/4

ViewModel

Although the show is no longer in production, you can enjoy episodes from the TWiT Archives.
Guests: Louis Maresca
Category: Help & How To

The Code for today's show is available below:
Build an App 1/4 - API

Want a safer Internet surfing session? -- COWL! http://www.sciencedaily.com/releases/2014/10/141006085130.htm

  • Researchers from "University College London", Stanford, Google, Chalmers, and Mozilla.
  • They've developed the "Confinement with Origin Web Labels" system that works with Google Chrome
  • It prevents malicious code in a web site from leaking sensitive information on a users' computer to third parties while still keeping cross-server connectivity. (the ability to call on multiple servers at once to complete a page load.)

In a Nutshell:

  • COWL uses "confinement" -- which has been around since the 70's but is difficult to implement when we have the need for data from multiple sources.
  • If a Javascript requests information from the computer or another website, that data transfer will be allowed
  • But then the application (script) that has received the information is prohibited from sharing it with unauthorized parties.
  • The information can come in... but it can't get out unless it's going to an application that is expressely allowed by the system.

Ivory Tower
In the last episode, we talked about using APIs to access information on Google's Servers.

  • If we were to put this in the context of the MVVM model. (Model View View Model), we worked on the Model.
  • Our code allowed the model to access external data and bring it into the program.
  • Today, we need to play with the ViewModel -- The part of the program that's going to put that external data into a format that is useful and determine WHAT data will be useful to the "View"

MVVM Rehashed!
This is how the "MVVM" (Model View ViewModel) pattern works

The "Model"

  • An object that contains all the data and information that we have to use.
  • It can also contain the API's that are necessary to GET the data and information that we have to use.
  • In a App... the "Model" is our bridge to the outside world

The "ViewModel"

  • This is the "interface" between the Model and the View
  • This is the piece that introduces "Presentation Separation"
  • It gets to decide which data from the model is place in the View
  • It gets to decide which input from the view (from the user) is pushed back to the Model

The "View" is the UI: It's the later that the User interacts with. Some call it the "presentation". The View can take the data and information contained within the "Model" object and organize it in order to make it more presentable to the user. In MVVM, the "View" is 'active' -- That means that is "aware" of the "Model". It can change and reorganize depending on the data that is in the "Model".

Let's talk about "Data Binding"

  • In it's most simple form, "data binding" is programming to establish some sort of connection between the UI and the "Business Logic" or data
  • We "BIND" because we want the UI to change depending on what's happening with the Data.
  • In our example... we want the UI to represent the data that is being pulled and prepared

Get in Touch With Us!

Bandwidth for Coding 101 is provided by CacheFly.