Anti Patterns
Anti Patterns
If design patterns are the good guys, then the anti-patterns are the bad guys. And sometimes a
good guy can turn into a bad guy. This happens in Hollywood movies, but it also happens in
software engineering.
The "golden hammer" is a favorite notion of this problem: you learned to use a tool in one context
(the golden hammer), and now because you are so proud having learned how to use this
complicated tool, all of a sudden you see golden nails everywhere.
A good example is the Singleton pattern: it is so easy that it is the first pattern most beginning
software engineers understand and henceforth, since presumably it is a good guy, they will use it
at every possible occasion. However, the problem with the Singleton is that it violates information
hiding. Now information hiding is one of the sacred cows of modern software engineering, and it
should be violated only when there is a really good reason for it. And just having learned about
the Singleton pattern is not!
In software engineering, an anti-pattern is a pattern that may be commonly used but is ineffective
and/or counterproductive in practice.[1][2] The term was coined in 1995 by Andrew Koenig,
[3]
inspired by Gang of Four's book Design Patterns, which developed the concept of design
patterns in the software field. The term was widely popularized three years later by the
book AntiPatterns,[4] which extended the use of the term beyond the field of software design and
into general social interaction. According to the authors of the latter, there must be at least two
key elements present to formally distinguish an actual anti-pattern from a simple bad habit, bad
practice, or bad idea:
Death march: Everyone knows that the project is going to be a disaster – except the
CEO. However, the truth remains hidden and the project is artificially kept alive until
the Day Zero finally comes ("Big Bang"). Alternative definition: Employees are
pressured to work late nights and weekends on a project with an unreasonable
deadline.
Groupthink: During groupthink, members of the group avoid promoting viewpoints
outside the comfort zone of consensus thinking
Lois Lane planning: Over-commitment by management / sales leading to the need to
be rescued by IT often leading to rushed development, mistakes, fatigue, the delay
or stoppage of more important long-term projects and the emboldening of decision
makers to repeat the risky behavior
Smoke and mirrors: Demonstrating how unimplemented functions will appear
Software bloat: Allowing successive versions of a system to demand ever more
resources
Waterfall model: An older method of software development that inadequately deals
with unanticipated change
Analysis anti-patterns[edit | edit source]
Bystander apathy: When a requirement or design decision is wrong, but the people
who notice this do nothing because it affects a larger number of people
Software design anti-patterns[edit | edit source]
Anemic Domain Model: The use of domain model without any business logic. The
domain model's objects cannot guarantee their correctness at any moment, because
their validation and mutation logic is placed somewhere outside (most likely in
multiple places).
BaseBean: Inheriting functionality from a utility class rather than delegating to it
Call super: Requiring subclasses to call a superclass's overridden method
Circle-ellipse problem: Subtyping variable-types on the basis of value-subtypes
Circular dependency: Introducing unnecessary direct or indirect mutual
dependencies between objects or software modules
Constant interface: Using interfaces to define constants
God object: Concentrating too many functions in a single part of the design (class)
Object cesspool: Reusing objects whose state does not conform to the (possibly
implicit) contract for re-use
Object orgy: Failing to properly encapsulate objects permitting unrestricted access to
their internals
Poltergeists: Objects whose sole purpose is to pass information to another object
Sequential coupling: A class that requires its methods to be called in a particular
order
Yo-yo problem: A structure (e.g., of inheritance) that is hard to understand due to
excessive fragmentation
Hurry up and wait: One or more asynchronous events triggered in the constructor of
an object
Programming anti-patterns[edit | edit source]
Copy and paste programming: Copying (and modifying) existing code rather than
creating generic solutions
Golden hammer: Assuming that a favorite solution is universally applicable (See:
Silver Bullet)
Improbability factor: Assuming that it is improbable that a known error will occur
Not Invented Here (NIH) syndrome: The tendency towards reinventing the
wheel (Failing to adopt an existing, adequate solution)
Premature optimization: Coding early-on for perceived efficiency, sacrificing good
design, maintainability, and sometimes even real-world efficiency
Programming by permutation (or "programming by accident"): Trying to approach a
solution by successively modifying the code to see if it works
Reinventing the wheel: Failing to adopt an existing, adequate solution
Reinventing the square wheel: Failing to adopt an existing solution and instead
adopting a custom solution which performs much worse than the existing one
Silver bullet: Assuming that a favorite technical solution can solve a larger process or
problem
Tester Driven Development: Software projects in which new requirements are
specified in bug reports
Configuration management anti-patterns[edit | edit source]