Justin Meyer

Jupiter IT

Present

JavaScriptMVC

JavaScriptMVC

Develop With Direction

Info

Features

Overview

  1. Why you should care. 2 min
  2. Problems. 4 min
  3. Solutions. 10 min
  4. Demo. 10 min
  5. Future. 2 min
  6. Conclusion. 1 min

Why you should care.

The last thing the world needs is another JavaScript Library - Everyone

Prototype, jQuery, Dojo, YUI, Ext, MochiKit, Open Rico, Moo Tools, etc

Why you should care.

JavaScript is #1

Why you should care.

The future is JavaScript


More JavaScript Code!

More Code == More problems

Problems.

Developers need to confront the same problems of any large software project.
Common problems:


JavaScriptMVC attacks these problems with best practices.

Solutions.

QualityDev. TimeMaintainability
Test FixturesInclude
Easy Update Code GeneratorsFile structure
Error Reporting Scaffolding Model
Plugins and Engines View
Controller
MVCDoc

Solutions > Quality

Test

an integrated and comprehensive JS testing suite

Provides:

Solutions > Quality

Update

Automatically update to the latest code.

js jmvc\update

Solutions > Quality

DamnIT

javascript error reporting


Features

Solutions > Dev. Time

Fixtures

substitute ajax responses


Use for:


//generate a fixture
js jmvc/generate/fixture get todos.json

//contents of /test/fixtures/todos.json.get
[{attributes: {id: 1, name: "take out trash"}}]

Solutions > Dev. Time

Code Generators

Quickly create code in the right place.


//creates a new app
js jmvc\generate\app APPNAME
//creates an html page
js jmvc\generate\page PAGE_LOCATION
//creates a controller
js jmvc\generate\controller CONTROLLER
//creates a model
js jmvc\generate\model MODEL_TYPE MODEL

Solutions > Dev. Time

Scaffolding

Get basic CRUD functionlity off the ground, expand from there.

Solutions > Dev. Time

Plugins and Engines

Install 3rd party code and dependencies from command line.

Splitter Fixed box Slider
 
Sortable Modal Tabs

Solutions > Maintainability

Maintainable code is ...

Solutions > Maintainability

Include

loads and compresses JS files


Features:

Use

include('file1','../folder/file3',
        function(){ ... })

Compress

js apps\APP_NAME\compress.js

Solutions > Maintainability

File structure

standard file structure


Solutions > Maintainability

Class

simulated class object


Features:
Monster = Class.extend("monster",{},{})
SeaMonster = Monster.extend("sea_monster")

Solutions > Maintainability

Logically Separated Code


What's in JS app?


We've broken these down into model-view-controller.

Solutions > Maintainability

Model

Wraps data layer


Wraps app's data layer in 2 ways:


Features:

Solutions > Maintainability

Model

Example


Todo = JsonRestModel('todo',{ 
  days_remaining: function(){ 
    return (this.date - new Date()) / 
		   (1000*60*60*24);
  }
})

Todo.find('all', function(todos){
  for(var i = 0; i < todos.length; i++)
    alert(todos.days_remaining());
})

Solutions > Maintainability

View

JS templating library


Features:


Example:

<h1><%= title %></h1>

Solutions > Maintainability

Controller

Responds to events


Features:


Solutions > Maintainability

Controller


HTML

<div class='todo todo_5'>
  <input class='complete' type='checkbox'/>
  <div class='handle'></div>
</div>

Controller

TodosController = Controller.extend('todos',{
  ".complete change" : function(params){ 
    var todo = params.class_instance()
    todo.complete();
  },
  "todo.complete subscribe" : function(t){...},
  ".handle dragstart" : function(){...}
})

Solutions > Tools

MVCDoc

JS based documentation engine


Features:


/**
 * Blah Blah Blah
 * @param {Controller.Params} param  */
dispatch: function(param){

Demo

Future

JMVC 2.0

Changes


New Features

Conclusion

What you should remember:

  1. Future -> More JavaScript
  2. More JavaScript == More Problems
  3. JMVC address many of these problems

For more info:

http://javascriptmvc.com
http://jupiterit.com
http://twitter.com/justinbmeyer
justin@juptierit.com
0