The best code I never wrote

To what extent does following “best practices” stand in the way of our opportunities for innovation? Conventional wisdom tells us that results will be better if everyone follows their industry’s best practices. But if we all did that, where would progress come from?

There are best practices in virtually every software development group, which have emerged over time as optimal ways to perform certain tasks in the context of a specific project or product. For example: there’s a known list of classes you need to create when implementing a new remote operation between components A and B, a third-party library must be integrated in the product in a certain way, and the already implemented message queue receivers indicate the structure that a new one should have. Knowing and following these guidelines is usually very useful and accounts for the wide gap in terms of effectiveness and efficiency between a newcomer and a veteran of the group.

But how about those times when these practices are not really, or no longer, the “best”? Maybe the product’s first message queue handlers were written before the Executors framework was added to the Java Development Kit; maybe Maven and OSGi were not yet mainstream at the time when the first 3rd party libraries were added to the project; and maybe there’s a whole group of related remote operations that can easily share the same message classes instead of each having its own ones. Maybe today, or in the current context, there is a better way.

Such opportunities for innovation and improvement stare us in the face on a daily basis, and when they do, we can choose to either pursue them or to take refuge in the comfort and security of tradition. I can tackle a challenge that resembles one I encountered in the past and think: “Great, I already wrote the best code to deal with this kind of problem!” or I can think instead: “I wrote something like this a while ago, but how can I do it better this time?”. Personally, I find the second attitude considerably more rewarding, and not just because it consistently produces better results over time, but also because it makes every work day much more interesting.

So if you ever happen to get bored at work, try this: stop for a moment, take a step back and examine how you’re doing whatever you happen to be doing at that time. Then ask yourself: “If I knew for sure that there was a better and more interesting way to do this, what would that way look like?”. Try the new way, enjoy the change, and every once in a while witness the birth of a new best practice!