DEV Community

Augusts Bautra
Augusts Bautra

Posted on

A developer's instincts

It seems to me that the genetic success of the human species primarily stems from our brains, and subsequently minds, being excellent general pattern matching and problem solving engines.

It is also reasonable to believe that much of the proficiency and speed of thinking (at least in comparison to other species) comes from evolved heuristics, hacks, if you will, that sacrifice precision for performance.

It ought also be appreciated that evolved mechanisms usually have two components - selective advantage, yes, but also reinforcing feedback (pain for avoidable things, pleasure for preferable things). For example, in science elegant theories are extolled as preferable. Occam's razor, a similar idea, encapsulates the heuristic that uncomplicated is preferable. This preference is felt on a very basic, pain-pleasure level.

So, we have certain evolved gut-feelings about processes and ideas that are not always correct, but are surprisingly often in the right direction. We should avail ourselves of insights gleaned this way!

As far as writing software is digital problemsolving, relying, or at least listening to, one's gut ought to be a common tool in a developers arsenal. Furthermore, I believe training existing instincts and developing new knee-jerk reactions should be an activity developers engage in often.

Positive heuristics

Most1 of what you find to be "good code", that is pleasing to the eye and gives you a warm feeling in the stomach matches some dictum you read on the internet somewhere.

Existing design patterns and best practices are a form of positive heuristic - you need not think too hard about them, you can instead rely on crowd wisdom, a form of evolution of ideas, to tell you that following them is good.

Things that have worked for you or others are common positive heuristics, use them. If some code pattern feels good to you and nobody on the team objects, keep using it!

Negative heuristics

A friend of mine has a saying: "There are infinitely many ways to do things incorrectly, but only a couple to do things right". Meaning it's significantly less use to know how not to do something rather than knowing exactly how to do it right. Nevertheless, often avoiding pitfalls is the best we can do, especially if the best, correct way to do a thing is still not determined, as is often the case in software development.

An easy way to generate negative heuristics is to read other's code. 😆

But seriously2, anything that makes you go "I wish I didn't have to keep seeing this", be it specs that run for hours and fail intermittently, loops in view templates or ̶j̶a̶v̶a̶s̶c̶r̶i̶p̶t̶, is probably an antipattern and you should trust your developer instinct that whatever it is that is raising your hackles is just bad and in need of refactor.

1 Avoiding O! algorithms being a notable, mathematically provable exception.
2 Meant half-unironically, take with a grain of salt.

Discussion (0)