Published on

A few common coding fallacies that go against intuition


I mainly blame it on the way we're thought to code. We supra-optimize algorithms way before we're able to do anything useful with them. When we finish school, reality settles and software development is quite a different discipline than we'd have expected. At least that's what happened to me. Here are my five, unexpected and somehow funny fallacies.

  1. You're not spending nearly as much time writing code as you do reading and understanding it. The main task of a software developer is to manage complexity and fit abstract data types to real-life problems. Don't let over-minimalistic approaches drive your designs: comment your code, prefer clean, verbose implementations to obscure and "witty" ones, wrap external dependencies, shamelessly duplicate code if needed, and so on.

  2. Performance makes a poor argument for, or against, a design decision Performance doesn't matter, until it matters. You shouldn't consider it at all before you measure the impact it has on your system. In other words, when bringing the performance argument, you need supporting hard data, otherwise, it's over-optimizing and it will just slow you down.

  3. Naming is one of the most difficult things in software development Use every means at your disposal to correctly name things, even if you have to spend time researching a proper name (i.e. by using a dictionary or the web). Naming is documenting. Also, many times when you can't find a proper name for a variable, field, or class, there's a good chance a design problem is lurking in the dark.

  4. Reusability is not critical, not even close There are many worthy goals you can pursue while writing software, but to my younger-self surprise, reusability is at the bottom of the list. Don't design thinking you'll reuse the code two years from now, in some unknown project that may or may not emerge. That will unnecessarily complicate things. A better approach would be to extract components at the end of each project, deciding what to keep while having a good overview, more time, and cost control.

  5. Errors are your friend. Handle them wisely While coding, there will be many situations when, under certain conditions, your routines can't complete their task. Handle every error and exception and weed out your true enemy: the unexpected behavior. Don't hide anything under the rug. Ignoring things doesn't magically make them go away.