Modularity

When writing large JavaScript applications, the key is to keep your source code well-organized and structurally sane. Unfortunately, JavaScript doesn't inherently support the idea of modular code very well right out of-the-box. To solve this problem, two popular libraries exist to allow you to write modular code and to rely on only the modules you need within each individual piece of code.

An absolute must-read and incredible resource for frontend design patterns is Addy Osmandi's Learning JavaScript Design Patterns, which you can read for free by visiting the following URL:
http://addyosmani.com/resources/essentialjsdesignpatterns/book/

Require.js and Browserify are two of the most popular module loaders today. Each has a very unique syntax and its own set of benefits. Require.js follows asynchronous module definitions, which means each piece of code needs to define its own dependencies. Personally, I've worked with Require.js in the past, and I've recently found that I really like working with Browserify. One of Browserify's strengths is that it uses the same modular pattern as Node.js; so, writing frontend code using Browserify feels identical to that of Node. You use module.exports and require on the frontend, and you don't have to worry about the syntax context switching if you go back and forth between Node and the frontend within the same application.

Using a module loader in conjunction with one of the popular MVC frameworks mentioned earlier is almost a requirement, because the two go together like peanut butter and jelly!

For more information, visit the following links:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.32.222