All articles


5 coding tips that go against your intuition

beginnersbest practicessoftware design
11 Feb 2020

Software design is a heuristic process: there's no bulletproof recipe for success. We iterate and learn as we go while common sense and previous expertise guide us. But sometimes, our common sense fails. Here are five misconceptions about coding and software design and how to avoid them.

  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 Contrary to what you might have learned in school, performance doesn't matter, until it matters. That is, 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 around.

  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 actually 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.