Questions tagged [anti-patterns]

A programming anti-pattern is a commonly used solution to a specific programming problem, often claiming being an actual design pattern. But such a solution usually leads to adverse effects on an application scalability, testability and maintenance.

An anti-pattern can be thought of as a "worst of breed" solution to a problem in that it may "work" for its intended purpose, but have unwanted side effects or incur technical debt. Anti-patterns can arise from improper education, insufficient experience or simple ignorance.

SQL-Injection

In short, this is an anti-pattern of applying unfiltered user input directly to a database query string. This may seem like a quick and easy solution to querying data, however it can lead to data corruption, security breeches, and so-forth.

Example:

query-string = "select * from users where id='" + userid + "';"

Assuming the userid variable came directly from the user, an attacker can cause issues by setting the value to something that would cause unexpected behavior:

userid = "' or 1=1;drop table users"

Tight coupling

Instead of keeping two distinct parts of an application separate (CSS and HTML; Business Logic and the View in an MVC application), the parts are mingled such that a change in one necessitates a change in the other.

Example:

CSS

.yellow { color: yellow; }

HTML

<div class="yellow">foo</div>

In order to change the formatting, either the content (HTML) must be changed by substituting a different class name, or the class definition (CSS) must be changed to something that doesn't match its name.

Others

Wikipedia has other examples.

440 questions
5
votes
2 answers

Can code that produces deep call stacks be considered as an anti-pattern?

We are doing a research around LLVM libraries and we have found that the IR library sometimes reaches call stacks up to 29 method calls. Sometimes when I see some crashes in iOS frameworks I also observe quite deep call stacks. My question is…
Stanislav Pankevich
  • 11,044
  • 8
  • 69
  • 129
5
votes
4 answers

Database as IPC antipattern

I've written a layered web application that consists of a rich-web client (PHP) that interacts with a java service. The web client is hosted on an apache server, and the java service runs on the same physical machine (to reiterate: the entire app,…
meta.matt
  • 312
  • 1
  • 5
  • 14
5
votes
2 answers

What are horizontal and vertical design elements?

I was going through this article on Architectural Anti-Patterns and it talks about horizontal and vertical design elements getting intermixed to form an unstable architecture. I was not able to google the definition of these terms.
s4san
  • 319
  • 2
  • 9
5
votes
1 answer

Naming of an algorithmic antipattern

I'm having problems to recall the name of doing something with quadratic complexity when it can be solved linearly. For example, using a get-by-index function to iterate over a linked list instead of just using a next-element is the typical case of…
fortran
  • 74,053
  • 25
  • 135
  • 175
5
votes
7 answers

How to deal with monstrous Struts Actions?

I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a specific question regarding Actions. Most of the pages have exactly one Action, and the processExecute() methods are hideous monsters (very long and tons of nested if…
thvo
  • 1,532
  • 2
  • 15
  • 29
5
votes
3 answers

Hand off instance before constructor returns

I have the habit of breaking the rules if it makes my code more concise or my API more convenient to use, and if I can thoughtfully get away with doing so in the specific circumstances. I'd like to know if I can get away with the following such…
HappyNomad
  • 4,458
  • 4
  • 36
  • 55
5
votes
6 answers

Has using an acknowledged anti-pattern ever been proven to actually solve a problem, or be beneficial in any other way?

Has using an acknowledged anti-pattern ever been proven to actually work in a certain specific case? Did you ever solve a problem or gain any kind of benefit in one of your projects by using an anti-pattern?
luvieere
  • 37,065
  • 18
  • 127
  • 179
5
votes
1 answer

Design patterns - anti pattern call super - avoid or keep

I recently noticed that something I actually liked doing in certain cases (call super) is an anti-pattern. (http://en.wikipedia.org/wiki/Call_super) So my question is: How to do the following thing (a basic thing that most of us need, add some…
zozo
  • 8,230
  • 19
  • 79
  • 134
5
votes
2 answers

jQuery (anti-)pattern: building selectors with string manipulation

Too often I find myself building selectors with string manipulation (split, search, replace, concat, +, join). Good or bad?
flybywire
  • 261,858
  • 191
  • 397
  • 503
5
votes
3 answers

Constructor specialization in python

Class hierarchies and constructors are related. Parameters from a child class need to be passed to their parent. So, in Python, we end up with something like this: class Parent(object): def __init__(self, a, b, c, ka=None, kb=None, kc=None): …
Mark Visser
  • 2,469
  • 1
  • 22
  • 16
4
votes
1 answer

Why the Service Locator is a Anti-Pattern in the following example?

I have a MVC application with a Domain Model well defined, with entities, repositories and a service layer. To avoid having to instantiate my service classes inside my controllers, and thus, mess my controllers with logic that does not suit they, I…
4
votes
4 answers

Too much singletons in the project - is it a bad practice?

In almost every project I create a few classes which implement Singleton pattern. For example, data manager - if there's some work with file system, data loader - if an application connects to the internet, different resources managers, etc.…
Sergey
  • 11,548
  • 24
  • 76
  • 113
4
votes
1 answer

Is inheriting from the EventEmitter an antipattern?

It appears to be common practice to inherit from the EventEmitter if you want your class to support events. For example Google does it for Puppeteer, the WebSocket module does it, mongoose does it, ... just to name a few. But is this really good…
Forivin
  • 14,780
  • 27
  • 106
  • 199
4
votes
3 answers

Bad idea to put a dom operation inside a redux reducer?

I have several actions which use the same reducer, and instead of having a dom operation in each of those actions, I want to just add it once inside my shared reducer. I know reducers are to be pure (which the returned data still is), but is this…
ram
  • 680
  • 5
  • 15
4
votes
4 answers

Are staging tables / staging databases an anti-pattern?

Are staging tables an anti-pattern that is used when rpc (such as Java RMI or some kind of Web Service call) or messaging queue (such as JMS) would be a better solution, or are there problems better served by staging tables? To clarify: By staging…
sal
  • 23,373
  • 15
  • 66
  • 85