Part 2. Managing complexity

 

The second part of the book is more interactive than the first, as it contains even more practical code samples. You’ll get to explore different little angles at which we can attack complexity in our application designs, such as modularity, asynchronous programming patterns, testing suites, keeping your code concise, and API design principles.

Chapter 5 is a detailed examination of modularity in JavaScript. We start with the basics, learning about encapsulation, closures, and a few quirks of the language. Then we delve into the different formats that allow us to build modular code, such as CommonJS, AMD, and ES6 modules. We’ll also go over different package managers, comparing what they bring to the table.

Chapter 6 teaches you to think about asynchronous code. We’ll go through tons of practical code samples, following a few different styles and conventions. You’ll learn all about Promises, the async control flow library, ES6 generators, and event-based programming.

Chapter 7 aims to expand your JavaScript horizons by teaching you about MVC. You’ll take a fresh look at jQuery and learn how you could be writing more modular code instead. Later on, you’ll leverage the Backbone.js MVC framework to componentize your front-end efforts even further. Backbone.js can even be used to render views on the server side, and we’ll leverage the Node.js platform to do exactly that.