See all glossary terms

Best possible code

There are a lot of beliefs about what is the best code, but almost all of it is subjective.
There are a many parameters that can be used to determine if a code is good or not. For example:
  • Time required to write new features
  • Development team happiness
  • Market Revenue
  • Amount of bugs
  • Fitness to requirements
  • Speed at fixing new bugs
  • Customer satisfaction
  • Running speed
  • Amount of crashes
  • ...
Programmers say that some methods increase such or such metric. Methods like:
  • Object Oriented Programming is supposed to make code easier to read and more fitting requirements.
  • Test Driven Design is supposed to lower the amount of bugs.
  • Functional Programming is supposed to lower the amount of bugs too and make them faster to fix.
  • Strong Typing is supposed to increase the comprehension of code and make bugs harder.
  • Diagrams design is supposed to increase customer satisfaction.
  • Agile methods are supposed to deliver better features faster.
  • ...
We've been studying all the metrics above, and others, and all those methods, more or less since programming exists. And in about 60 years of studies, the resounding answer is: we do not know.
There are no clear numbers demonstrating any method is better than any other, on any of those metrics. There are a lot of studies demonstrating programmers believe such or such method is better, but that is not supported empirically.
In other words, all methods seem relatively equivalent generally (some may be better in specific cases).
There are a few things we do know increase code quality (accross all metrics):
  1. Amount of sleep
  2. Pair programming and code reviews
These two elements increase all metrics. So make sure you get good sleep, and that you show your code to others!
To know more about such things, here's a youtube playlist with good talks about empirical approaches to software engineering: