What is the Golden Hammer Anti-Pattern?

The Golden Hammer anti-pattern (formally and originally called the Law of the Instrument) is an over-reliance on a familiar tool. The gist of this anti-pattern is summed up as "If all you have is a hammer, everything looks like a nail."

Generally, people fall into this anti-pattern if they try to use a particular tool, architecture, suite, or methodology to solve many kinds of problems (especially problems that could be better solved by alternate means). They are often doing this for one of two reasons:

They are very familiar with that tool set or framework and believe that it can be used to solve many problems OR

They spent a lot of money acquiring the tool set or framework and need to justify this cost (hence why it's a Golden hammer).

Show Me an Example!

Ben is a new web developer, after having formerly been a database administrator, and he's been given his first task in this new role. His lead has asked him to implement a new website, one that will be displaying some static content to a small set of visitors in his company.

Ben, having dealt with these kinds of applications before on the database side, immediately begins laying out the database design for this new app. A simple schema and a few hours later, he presents his design to his lead Paula, who has to explain to him that the website isn't expected to change its content frequently enough to warrant using a database at all.

The website was displaying static content, e.g. content that would not change often. Ben had picked up his golden hammer and tried to use it to solve a problem that it wasn't really needed for.

When Does This Happen?

Many times this anti-pattern is perpetrated by individuals who have had past successes with a given technology, but are trying to use that technology to solve a problem that does not require the technology's existence.

In addition to seeing this result from inexperience (like Ben), we also see this coming from the management side. Has your manager ever said to you "Please use Technology Suite A for your solution" even if you found that Technology Suite B could implement the solution better? If the manager's suite was preferred because s/he knew it better, or because the company spent a lot of money acquiring that technology, that manager was (probably) falling victim to his/her own golden hammer.

How Can We Avoid This Anti-Pattern?

Evidence is your best weapon when combating this anti-pattern. You need evidence that shows why Technology Suite B outperforms Technology Suite A for a particular problem, and you need to be able to convince the people in charge of making decisions as to why Suite B is a better choice.

Experience is also an important weapon, but it isn't listed first because it is harder to acquire. The more experience you gain when designing and implementing non-trivial software systems, the more likely you are to recognize a golden hammer and not pick it up without analyzing the other possible solutions first.

For a wonderful in-depth writeup on this anti-pattern, check out the article over at SourceMaking.

Have you ever been a golden hammer wielder, and did you notice that you were doing such? How have you combated this anti-pattern in your job? Let me know in the comments!