现在的位置: 首页 > 综合 > 正文

Javascript MVC2.0(javaeye)

2013年10月14日 ⁄ 综合 ⁄ 共 4778字 ⁄ 字号 评论关闭
文章目录

 

1.Why JavaScriptMVC    

Bad developers copy. Great developers Steal!

JavaScriptMVC has 'stolen' all the greatest ideas in JavaScript development and integrated them into one convient package. Read how JavaScriptMVC:

  • enforces best practices
  • improves maintainability
  • reduces development time
p.s. Jupiter provides affordable JavaScriptMVC and jQuery training and support.

Best Practices

Compression

Effortlessly include and compress JavaScript files no matter how complex the dependencies. Because it's so easy, there's little incentive for developers to lazily group unrelated functionality in the same file.

Testing

JavaScript testing sucks and almost always fails. JavaScriptMVC's Selenium, Rhino, and browser test integration provide a fast, comprehensive, and easy to author testing environment.

Documentation

Like testing, documentation is one of those things that we need to do, but avoid. JMVC makes this easy and automatic. This entire site is written in JMVC's source and generated from its documentation engine.

Error Reporting

Getting JavaScript to work perfectly across all browsers is extremely challenging, if not impossible. JavaScriptMVC sends you an email when your application breaks by integrating with the http://damnit.jupiterit.com service.

Updating

Staying current with the latest code is as simple as writing:

js jmvc/update

Maintainability

Class

jQuery.Class provides simple simulated inheritance in JavaScript and other awesomeness: class level inheritance, class initialization callbacks, introspection, instance class access.

Model

Models organizes an application's data layer. This is done in two ways:

  • Requesting data from and interacting with services
  • Wrap service data with a domain-specific representation.

Controllers and Event Delegation

JavaScriptMVC's controllers use event delegation to organize event handlers. They are JavaScriptMVC's best and most unique feature.

Views

Views are client side templates that avoid mixing HTML and JavaScript. Don't add strings to create HTML!

Reduce Development Time

Fixtures

Fixtures are simulated Ajax responses. Use them to sever your front end development dependency on the backend. Your (sexy, smart) frontend team won't have to burn cycles waiting for the (ugly, stupid) backend team.

Scaffolding

Scaffolding generates the code you need to manipulate a service. Its a great way to get something working up quickly. It even makes tests to test the generated code.

Code Generators

JavaScriptMVC is packed with code generators. Generate application and file stubs via the command line:

js jmvc/generate/app email_manager
js jmvc/generate/controller emails
js jmvc/generate/model user
js jmvc/generate/test email
js jmvc/generate/page email_manager index.html

Plugins and Engines

Engines are community built pre-packaged widgets. Install them from the command line.

 

 

2.Learning    

JavaScriptMVC contains pretty much everything you need to develop, test, and maintain a JavaScript application. Instead of learning an API, learning JavaScriptMVC is more about learning HOW to build an application.

The Basics

Watch 2.0 Video Before you do anything, watch the 2.0 Video. It's a 12 min brain dump that will highlight most of JMVC's features.

You might be asking yourself a fequently asked question:

Model View Controller

There are only 4 things you will ever do with JavaScript! JMVC breaks these down into the Model-View-Controller architecture

  1. Respond to events -> Controller
  2. Get data and manipulate services (Ajax) -> Model Static functions
  3. Wrap service data with domain specific information -> Model Prototype functions
  4. Update the page -> Controller and View

Here's how that flow looks:

Think how this would work with the google auto-suggest.

  1. Respond to typing "JavaScriptMVC" -> Controller.
  2. Get search suggestions -> Model Static functions.
  3. Wrap search data -> Model Prototype functions. Not really important here!
  4. Draw suggestions -> Controller and View.

Development Tools?

JavaScriptMVC supplies a host of JS tools including:

How do I get help?

Write on our forum.

How do I report errors, or contribute code?

Submit patches or errors in google code.

抱歉!评论已关闭.