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
14
votes
5 answers

`return $this;` design pattern or anti-pattern?

I've seen many times Zend Framework using return $this; pattern style - and from my point of view: Pro: seems its quite not bad pattern style for chaining many actions on the same object and making your code shorter. Con: code looks a bit weird…
Laimoncijus
  • 8,615
  • 10
  • 58
  • 81
14
votes
6 answers

Bad real-world database schemas

Our masters thesis project is creating a database schema analyzer. As a foundation to this, we are working on quantifying bad database design. Our supervisor has tasked us with analyzing a real world schema, of our choosing, such that we can…
Benjamin
  • 332
  • 2
  • 14
14
votes
2 answers

How do I NOT use DependencyResolver.Current.GetService(...) in this situation

Following the advice I have been given in this thread [Ninject UOW pattern, new ConnectionString after user is authenticated I now understand that I should not use the following line... var applicationConfiguration = …
Dib
  • 2,001
  • 2
  • 29
  • 45
13
votes
18 answers

Performance anti patterns

I am currently working for a client who are petrified of changing lousy un-testable and un-maintainable code because of "performance reasons". It is clear that there are many misconceptions running rife and reasons are not understood, but merely…
Xian
  • 76,121
  • 12
  • 43
  • 49
13
votes
3 answers

Change value of parameter inside method, is this an anti-pattern?

So something like this public void MyMethod(object parameter) //.... BuildSomething(parameter); BuildLayers(parameter); BuildOtherStuff(parameter); } public void BuildSomething(object parameter) { //... parameter.SomeProperty =…
roundcrisis
  • 17,276
  • 14
  • 60
  • 92
13
votes
4 answers

If Singletons are so bad, why does Scala have language support for them?

Possible Duplicate: Why are singleton objects more object orientated? Why does Scala have language support for the Singleton anti-pattern? If Scala had inherited the static keyword from Java, what legitimate use cases of the object keyword would…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
13
votes
3 answers

Is replacing a list element an anti-pattern?

I have a module that works on paths represented as lists. Most of the functions do typical recursive list processing, but now I need one that sometimes mutates a path. So, I wrote this replace function: module List = let replace f sub xs = …
Daniel
  • 47,404
  • 11
  • 101
  • 179
12
votes
7 answers

Need refactoring ideas for Arrow Anti-Pattern

I have inherited a monster. It is masquerading as a .NET 1.1 application processes text files that conform to Healthcare Claim Payment (ANSI 835) standards, but it's a monster. The information being processed relates to healthcare claims, EOBs, and…
Steve Owens
  • 218
  • 2
  • 7
11
votes
1 answer

How to fix React Warning : Can't perform a React state update on an unmounted component

Whenever if there is any asynchronous task performing related to component and that component unmounts then React generally gives this warning - Can't perform a React state update on an unmounted component This is a no-op, but it indicates a memory…
user15650989
  • 727
  • 2
  • 5
  • 8
11
votes
1 answer

What is the "Smart UI Anti-Pattern"?

In his book, Implementing Domain-Driven Design, Vaughn Vernon states, When there are User Interface views that render the model and drive execution of its behavior, these are also inside the Bounded Context. However, this does not mean that we…
11
votes
1 answer

React anti pattern, defined a component inside the definition of another component

I have read about the nested component in React. I tried with this example and noticed that each time I updated the state of the parent component (todolist). The DOM tree re-render the whole instead of add new. My question is: Is it an anti-pattern…
taile
  • 2,738
  • 17
  • 29
11
votes
7 answers

Is using "out" bad practice

I have just added an out bool parameter to a method I've written in order to get a warning in to my UI. I've used an out rather than getting the method itself to return false/true as that would imply the DoSomething failed/succeeded. My thinking was…
Antony Scott
  • 21,690
  • 12
  • 62
  • 94
11
votes
12 answers

What are some specific legitimate uses for singletons?

Possible Duplicate: On Design Patterns: When to use the Singleton? This question is not about whether or not singletons are "considered harmful" in general. I just want to know, from your experience, what are some SPECIFIC SITUATIONS in which…
Emile Cormier
  • 28,391
  • 15
  • 94
  • 122
11
votes
2 answers

When to use nested controllers instead of services in angularjs?

I just started to use AngularJS, so I'm not an expert. I have a div that represent the right area of my html view. In that div I have a controller, i.e.
...
Inside that div I have…
Miguel A. Carrasco
  • 1,379
  • 1
  • 15
  • 26
11
votes
6 answers

Is Ext JS's MVC an anti-pattern?

I work in a team of 25 developers. We use ExtJS MVC pattern of Sencha. But we believe that their definition of MVC is misleading. Maybe we might call their MVC an anti-pattern too. AMAIK, in MVC controller only knows the name or the path of the…
user1968030