Maintainable JavaScript – Writing Code Others Can Read and Support – #programming #bookreview

Maintainable JavaScript
Nicholas C. Zakas
(O’Reilly, paperback, list price $34.99; Kindle edition, list price $27.99)

If you work with JavaScript – alone or in a development group – or if you are still learning JavaScript, you need this book.

Three reasons why:

  • If you have learned JavaScript on your own, hoping to land a job with a big company, you likely have developed your own style of coding.
  • If you are just starting to learn JavaScript, you don’t have a coding style yet. But you are fresh meat for creating your own in the near future.
  • If you have recently started working as part of a software development team, you likely have just made a rather painful discovery. Your carefully honed own coding style is not acceptable for the work you have just been assigned. Very quickly you must adapt to new coding conventions (or style guidelines) enforced by your manager.

Maintainable JavaScript focuses on the importance of following strict style guidelines and creating code that others in a development team can easily understand, maintain, adapt and extend.

The author, Nicholas C. Zakas, has written two previous JavaScript books. His latest is drawn from best practices he observed, followed, and developed at Yahoo! over five years while he was front-end tech lead for Yahoo!’s homepage, as well as a contributor to the YUI library.

“When a team is brought together for the first time, everyone brings with them their own ideas about how code should be written, “ Zakas notes. “After all, each team member comes from a different background.” And: “Everyone has an opinion about how code should be written, and it usually falls in line with how that individual would personally write it. Establishing style guidelines should always come as early in the process as possible.”

His well-written 219-page book is organized into three parts and 20 chapters.

In the Style Guidelines part, the chapters are:

  • Basic Formatting
  • Comments
  • Statements and Expressions
  • Variables, Functions, and Operators

The Programming Practices part has these chapters:

  • Loose Coupling of UI Layers
  • Avoid Globals
  • Event Handling
  • Avoid Null Comparisons
  • Separate Configuration Data from Code
  • Throw Your Own Errors
  • Don’t Modify Objects You Don’t Own
  • Browser Detection

And the Automation part has the following chapters:

  • File and Directory Structure
  • Ant
  • Validation
  • Concatenation and Baking
  • Minification and Compression
  • Documentation
  • Automated Testing
  • Putting It Together

The book’s two appendices are “JavaScript Style Guide” and “JavaScript Tools.”

Maintainable JavaScript smoothly and cleanly covers a lot of important ground. It takes you from the often-debated guidelines for indentation — “indentation is about as close to religion as software engineers get,” Zakas says — to enduring the “pain point” of browser testing, and creating build directories for development, integration, and release builds.

Si Dunn

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s