My Software Development Principles

The following is an attempt to create a concise set of principles that will allow others to understand who I am (or perhaps aspire to be) as a software developer. These aren’t specific to any sort of software development methodology or paradigm and are in no particular order. These may be obvious to seasoned developers, but they are far from ubiquitous.

  • Write clear, readable code. I want others (as well as myself) to be able to quickly and thoroughly understand the code I’ve written. Code is not only communication with a machine or program but also with other developers.
// This
var byActiveDevice = item => item.device && item.device.active;
var activeUsers = users.filter(byActiveDevice);
// Not this
var activeusrs =usrs.filter((usr)=> {
if(usr.device && usr.device.active){ return true }
});
  • Follow a style guide. Having a codebase with a consistent style makes it easier to read; kind of like punctuation in writing. Airbnb has created a great one for JavaScript here and Mark Otto has created one for HTML and CSS here. Tools like jshint make this easier.
  • Write concise code. The less code there is in a codebase the easier it is to maintain. Avoid duplicating code (DRY) and building something before you need it (over-engineering).
// This
return user.active || device.active;
// Not this
if (user.active) {
return true;
} else if (device.active) {
return true;
} else {
return false;
}
  • Reduce complexity. As the level of complexity goes up so does the opportunity for creating bugs. Sometimes it can’t be avoided, but often thinking about the problem again after a first pass will expose opportunities to simplify the solution.
  • Use comments sparingly. Let the code speak for itself, but use comments for the logic surrounding the code if a competent developer wouldn’t be able to understand it.
// This
const offlineStatusCode = 1001;
if (response.device.status_code === offlineStatusCode) {
createPushNotification(response.device);
}
// Not this
// Device in response is offline
if (r.device.status_code === 1001) {
// Have to make another API request here to create a push
// notification
createPushNotification(r.device);
}
  • Employ Test-Driven Development (TDD) and Continuous Integration (CI). Regressions are demoralizing and can be reduced by writing tests. It’s far more efficient to automate the testing of code than to do it manually. It’s also easier to write high quality tests while developing a feature than after the fact.
  • Stand on the shoulders of giants. Use and contribute to open source libraries and language/framework features when possible. Implementing an existing system is probably more reliable and easier than building it from scratch.
  • Use the right tool for the job. Don’t be swayed by personal preferences or a technology’s current popularity. Sure, MEAN may sound cool but chances are you probably shouldn’t be using MongoDB.