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.