JavaScript Application Design: A book you likely need if you are working with, or still learning, JavaScript – #programming #bookreview

JavaScript Application Design

A Build First Approach

Nicolas Bevacqua

Manning – paperback

 

I didn’t know how much I needed this book until I started reading it and exploring its code examples.

Many of us who have worked with JavaScript started our connections to the language in very haphazard fashions. We learned some of it on the job, under deadline pressure to fix or update somebody else’s code. Or we took an introductory class or two and then started picking up whatever else we could on the fly, including the bad habits of others around us who seemed to know a bit more about JavaScript than we knew at the moment.

Unfortunately, JavaScript is a big, messy programming language, and it offers numerous opportunities to crash and burn if you really don’t know what you are doing.

In his new book, JavaScript Application Design, Nicolas Bevacqua makes a compelling case for using “the Build First philosophy of designing for clean, well-structured, and testable applications before you write a single line of code.”

He writes: “You’ll learn about process automation, which will mitigate the odds of human error…. Build First is the foundation that will empower you to design clean, well-structured, and testable applications, which are easy to maintain and refactor. Those are the two fundamental aspects of Build First: process automation and design.”

In his well-written text, he argues: “Front-end development requires as much dedication to architecture planning and design as back-end development does. Long gone are the days when we’d copy a few snippets of code off the internet, paste them in our page, and call it a day. Mashing together JavaScript code as an afterthought no longer holds up to modern standards. JavaScript is now front and center.”

He continues: “We have many frameworks and libraries to choose from, which can help you organize your code by allowing you to write small components rather than a monolithic application. Maintainability isn’t something you can tack onto a code base whenever you’d like; it’s something you have to build into the application, and the philosophy under which the application is designed, from the beginning. Writing an application that isn’t designed to be maintainable translates into stacking feature after feature in an ever-so-slightly tilting Jenga tower.”

Bevacqua divides his nine-chapter book into just two parts: build processes and managing complexity. Here is how the chapters are organized:

  • PART 1: BUILD PROCESSES
    1 – Introduction to Build First
    2 – Composing build tasks and flows
    3 – Mastering environments and the development workflow
    4 – Release, deployment, and monitoring
  • PART 2: MANAGING COMPLEXITY
  • 5 – Embracing modularity and dependency management
    6 – Understanding asynchronous flow control methods in JavaScript
    7 – Leveraging the Model-View-Controller
    8 – Testing JavaScript components
    9 – REST API design and layered service architectures

Bevaqua notes that “Linting is often referred to as the first test you should set up when writing JavaScript. Where linters fail, unit tests come in.” He strongly pushes testing and automation right from the start.

Linting soon leads to Grunt, which Bevaqua uses as a task runner and key build tool (with selected modules) in this book. “Grunt is a tool that allows you to write, configure, and automate tasks–such as minifying a JavaScript file or compiling a LESS style sheet–for your application,” he states. (It also works well on Windows machines, which I find handy.)

Grunt leads to running a bit of Node.js on the command line. And if you’ve never worked with Node.js, Bevacqua takes the reader smoothly through the process of installing it and using it in linting exercises. Indeed, he devotes an entire appendix (B) to installing and running Grunt and picking the right plugins for the right tasks and targets.

One of the best parts of this book, to me, is how the author uses short code examples to introduce a concept, and  then builds upon the examples with helpful descriptions and more short but expanded code samples.

Nicolas Bevacqua offers his readers plenty of helpful how-to and why information. Using his book, I have begun applying the Build First approach to some new projects and learning to how test and automate more of my work. I feel as if I now have a good shot at getting a lot better at JavaScript.

There is one small but important glitch to note: At two points in my preview copy of the book from Manning, Bevacqua shows what he calls a simple way to create bare-minimum JSON manifest files. For example, echo “{}” > package.json. Creating a blank, starting-point manifest file did not work this way for me. Instead, I had to use echo {“name: ” “project-name”} > package.json. The empty package.json issue apparently is somehow related to certain versions of Node’s npm.

Si Dunn 

Advertisements