Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

75 Code Quality

Good quality code is just as important as a clean project in Logic Pro. Scripts can get complex quickly and code blocks, functions, or even single lines of code can become convoluted and hard to remember their intent over time. The keys to managing that complexity is to be consistent in how the script is written and to clearly document the script’s intent and any changes.

This section serves as a style guide to writing code by moving beyond just the straight functionality provided in this book and providing guidance on how to make any code self-documenting. Some style conventions have already been established in the examples and are documented in the Syntax section below. This section will not get into all aspects of good code quality. Whole books have been written on that topic, like the excellent Code Complete by Steve McConnell, but much of that book goes beyond Scripter’s scope. This section focuses on what is most commonly, and arguably critically, needed for Scripter.

One thing which is important to remember with this guide is that ultimately everyone finds their own style. This section is offered as a collection of suggestions, and while many of them are tried and true, doing what is most comfortable is most important as long as it’s done consistently. Everyone eventually finds nuances which work for them and styles change with practice and experience. But no matter which style is settled upon, consistency is most important over the long term.