The Hammer Principle and Problem Solving

The hammer principle states that: “Never use a hammer to swat a fly off someone’s head.”

This simply means you shouldn’t suggest complex solutions to simple problems. Do not carry an armoured tank to a duel.

Swatting a fly off someone’s head with a hammer create more problems rather than the intended solution when the hammer strikes. It leads to more chaos and it’s is detrimental to the person’s wellbeing. It taints your good intention if you initially had one.

Attempting a simple task of swatting a fly off someone’s head with a complex tool (yes, complex in that situation) says a lot about your approach to problem-solving.

Problem-solving begins with identifying and defining the problems. Then, making effort to solve it using the tools and resources within your reach.

Whenever we need to solve a problem, especially in the computer science and software development context, we try to optimize the available resources.

Resources, as we all know it, are limited – space, time and power consumption. The issue of limited resources is at the core of theoretical computer science and its biggest open problem, P = NP attest to that fact.

So, using a hammer when you could use just your hand is like implementing a circular doubly linked list where a singly linked list will be enough. Though, they are always trade-offs to consider for every data structure or algorithms chosen. The bottom line is you don’t have to use a framework when a function in the standard library is just cool.

Even with complex problems, we try to break things down into solvable pieces. Then, we couple the solved pieces back into a whole solution. It’s called a divide and conquer approach in programming, and it’s implemented in algorithms like that of merge sort.

A simple solution is desired for a simple problem. Coupled simple solutions are also desired for a complex problem but this is not always the case. Some of the solvable pieces could be complex at times. As H.L Mencken aptly put it that “for every complex problem, there is an answer that is clear, simple and wrong”.

In conclusion, as you build your next project and solve a real life problem, always put in check the hammer principle. Only consider the hammer when there’s a need for it.

Published by peacelovingahmed

Olawale Ahmed Alamu, the Curator on this site is a final year undergrad of Computer Sciences at the University of Lagos, Nigeria. He's a curious learner and a lover of words, numbers and codes, which are the next basic building blocks of life after cells, atoms, bits and neurons. He plays with words and enjoys recreational mathematics while coding in his favorite programming language – Python. He has composed over 100 Puns and love reading about Prime numbers.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: