Ember.js – Architecture and Implementation – What is Ember.js



Ember.js – Architecture and Implementation – What is Ember.js

0 0


ember-architecture

Splainin some Ember Archs

On Github alvincrespo / ember-architecture

Ember.js

Architecture and Implementation

Created by Alvin Crespo / @alvincrespo

What you will learn:

  • What and Why Ember
  • Ember Framework Architecture
  • Ember Application Architecture

What is Ember.js

Ember is a JavaScript framework that aims to help developers create "ambitious web applications" that are scalable, performant and accessible.

Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).

Who is using Ember.js

Why should you care?

  • A focus on features, not coding
  • Promotes strict coding standards
  • Adheres to current methodologies
    • Standard JSON API's
    • Seperation of Concerns
    • Bookmarkable Routes

What makes a framework/library?

Library A library is essentially a set of functions that you can call [...]
Framework A framework embodies some abstract design, with more behavior built in.

Libraries

Backbone Backbone is an attempt to discover the minimal set of data-structuring [...] and user interface [...] primitives that are generally useful when building web applications [...]
Angular AngularJS is a toolset for building the framework most suited to your application [...]
React React is a [...] library for creating user interfaces

Frameworks

Ember A framework for creating ambitious web applications.

There are more: http://todomvc.com/

Qualities of a good Framework

Number 1

Where your code should be placed is clear.

Qualities of a good Framework

Number 2

You shouldn't have to write and maintain much code.

Qualities of a good Framework

Number 3

Changing code doesn't affect the whole application.

Seperation of Concerns (SoC)

When concerns are well separated, individual sections can be developed and updated independently.

Ember provides an architecture for managing an applications data model, logic and view presentation independently.

SoC Theory in Ember

SoC Practice in Ember

Routing

export Ember.Router.map({
  this.resource('assessments');
});

Ember creates and does a lookup on the following:

AssessmentsRoute.js
App.AssessmentsRoute = Ember.Route.extend();
AssessmentsController.js
App.AssessmentsController = Ember.Controller.extend();
AssessmentsView.js
App.AssessmentsView = Ember.View.extend();

SoC Practice in Ember

Routes

Routes handle the communication for retrieving a model:

// app/scripts/routes/assessments.js
export Ember.Route.extend({
    model: function() {
      // Hooking into our API's
      return $.ajax({ url: 'http://localhost:8888/assessments' });
    }
});
Specifying a Routes Model

SoC Practice in Ember

Controllers

// app/scripts/controllers/assessments.js
export Ember.Controller.extend({
  // A computed property that observes the models `name` property
  // and returns the an uppercase version of the name
  title: function() {
     return this.get('model.name').toUpperCase();
  }.property('model.name')
});
Associated Template
<section class="assessment">
  <header>
    <h1>{{title}}</h1>
  </header>
</section>
Decorating the Model with Controllers

SoC Practice in Ember

Views

// app/scripts/views/assessments.js
export Ember.View.extend({
  templateName: 'assessments/index.hbs',
  click: function(){
    // Handle a click event here
  }
});

User interaction is contained in your view. Associated templates can be defined here as well.

Handling user initiated events

Real World Example

Meet Ember.js: Not Just Another JS Framework

In Summary...

You should be using Ember.js because you get all of the following for free:

  • Architecture
  • Seperation of Concerns
  • Routing
  • Promises
  • Components
  • Testing Tools (Ember Extension)

Resources / Credit

Ember Guides

Meet Ember.js: Not Just Another JS Framework

Fluent 2014, "Keynote With Yehuda Katz and Tom Dale"

Ember and the future of the web

Building URL-Driven Web Apps with Ember.js

The End

BY Alvin Crespo / alvincrespo.me