Course contentsShow
← Computer Science
Lesson 2304 of 2,87251. Design PatternsFree lesson

Golden Hammer Anti-Pattern

Over-relying on a familiar technology or pattern for every problem, regardless of whether it's the appropriate solution.

Golden Hammer Anti-Pattern

What you'll learn: How over-relying on a single familiar tool or pattern can lead to poor design decisions and inefficient solutions.


The Core Idea

The Golden Hammer anti-pattern describes the tendency to apply one familiar technology, framework, or design pattern to every problem you encounter, regardless of whether it's actually appropriate. The name comes from the saying: "If all you have is a hammer, everything looks like a nail."

When developers become comfortable with a particular solution—whether it's a programming language, database, design pattern, or framework—they may unconsciously force-fit that solution to new problems, even when better alternatives exist.

How It Manifests

A team that loves the Singleton pattern might try to make everything a singleton, even objects that should naturally have multiple instances. A developer skilled in SQL databases might insist on using a relational database for storing unstructured log data that would be better suited for NoSQL or file-based storage. A company standardized on microservices might break down a simple application into dozens of services when a monolith would suffice.

The Golden Hammer isn't about the tool being inherently bad—it's about applying it indiscriminately without evaluating the problem's actual requirements.

Why It Happens

This anti-pattern stems from cognitive comfort zones. Learning new tools requires time and effort. Using what you already know feels faster and safer, especially under deadline pressure. However, this short-term convenience often creates long-term maintenance headaches, performance issues, and unnecessary complexity.

Avoiding the Golden Hammer

Combat this by regularly evaluating whether your chosen solution genuinely fits the problem. Ask: "Is this the best tool, or just the most familiar one?" Stay curious about alternative approaches, and be willing to learn new patterns or technologies when the situation calls for it.

Key Takeaway:
Don't let familiarity override fitness—choose solutions based on the problem's actual needs, not just what you already know.