Questions tagged [anti-patterns]

An anti-pattern is a behavior or practice that is common despite being ineffective or counterproductive.

In software engineering, an anti-pattern (or antipattern) is a pattern that may be commonly used but is ineffective and/or counterproductive in practice.

The term was coined in 1995 by Andrew Koenig, 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, 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:

  • Some repeated pattern of action, process or structure that initially appears to be beneficial, but ultimately produces more bad consequences than beneficial results, and
  • An alternative solution exists that is clearly documented, proven in actual practice and repeatable.

(excerpted from the Wikipedia article)

237 questions
230
votes
7 answers

What is wrong with magic strings?

As an experienced software developer, I have learned to avoid magic strings. My problem is that it is such a long time since I have used them, I've forgotten most of the reasons why. As a result, I'm having trouble explaining why they're a problem…
Kramii
  • 14,069
  • 5
  • 45
  • 64
17
votes
2 answers

What is the For-Case Antipattern?

Today's TDWTF article starts with a confession from the author: I didn’t know what the For-Case anti-pattern was until relatively recently, when there were a spate of articles condemning it as an anti-pattern. I’m sure I’ve probably used it, at…
Mark Amery
  • 1,250
  • 1
  • 14
  • 27
14
votes
13 answers

The difference between best practices and common sense?

There is a lot of conversation regarding best practices1 in software development. I've seen at least three major points get a lot of discussion both on SE and elsewhere: What qualifies as a best practice, and why? Are best practices even worth…
Ed Carrel
  • 595
  • 1
  • 5
  • 8
10
votes
3 answers

Is there a formal anti-pattern to describe the scenario?

Some code is written to generate Excel Spreadsheets (Office Interop). The code performs very poorly. A subsystem is designed to generate the files at night. Performance isn't a concern at night. A function is created to pick the correct file…
1
vote
1 answer

Does this anti-pattern have a name?

Here is a piece of cool code to add the two integers, a and b: NameService nameService = NameService.getSingletonInstance(); OperationService operationService = nameService.resolve(OperationService.class); ValueFactory factory =…
h22
  • 927
0
votes
1 answer

Finding a definition for this anti-pattern

Working on a large and multi-tiered software project, I just found a recurring anti-pattern to be occurring in the code. I coulnd't find its definition in Wikipedia or other sources after a quick search, so I would like to ask you if there is a…
-3
votes
2 answers

Name for unnecessary transcoding antipattern?

Say I have a library function that expects a JSON-encoded object and does some things with it: function foo(bar) { const baz = JSON.parse(bar); doTheThing(baz); doTheOtherThing(baz.qux); } Now I encounter an object that is not already…