Home 10 Tips for Writing Quality Code

10 Tips for Writing Quality Code

James Schorr, the owner of Tech Rescue has a guest post on the Ruby Learning blog where he asks “Do You Enjoy Your Code Quality?” He makes a strong argument for treating programming as craftsmanship writing that the goal of his article is to help people improve code quality and “transform the mundane into the beautiful.”

Schorr offers a number of tips for pre- through post-development of projects, and while some of his points may be geared towards independent consultants and independent developers, they’re pretty applicable to anyone:

Pre-Development

  • Gather all the requirements from clients up front. Schorr recommends thinking of these in terms of “stories” as “it’s more in line with how the non-developer thinks.”
  • Clarify what is necessary and what’s just “nice-to-have.”
  • Refuse to reproduce lousy code. In other words, turn down work if you’re going to be asked to reproduce a poorly designed system – unless you are being given the freedom to do it right. (This begs the question, of course: How do you define “lousy code”?)
  • Reject unrealistic timelines

Development

  • Out-engineer user-error as much as possible. “In other words,” writes Schorr, “never trust that the user will do what you expect, especially when entering data.”
  • Be open to including other languages and technologies where appropriate.
  • Don’t reinvent the wheel.

Post-Development

  • Review your code for speed, stability, security, and usability.
  • Have non-technical people do real-world testing on your product.
  • Revisit old code periodically and see what you would’ve done differently.

How do you achieve quality programming? What makes a bit of code into something like Schorr describes as “craftsmanship”?

About ReadWrite’s Editorial Process

The ReadWrite Editorial policy involves closely monitoring the gambling and blockchain industries for major developments, new product and brand launches, game releases and other newsworthy events. Editors assign relevant stories to in-house staff writers with expertise in each particular topic area. Before publication, articles go through a rigorous round of editing for accuracy, clarity, and to ensure adherence to ReadWrite's style guidelines.