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
6
votes
2 answers

GWT ClientFactory: Isn't this just a big blob/monolith?

The GWT ClientFactory seems to be a budding new design pattern for GWT apps, and although is not officially a part of the GWT API, is encouraged by GWT and is found in countless GWT/MVP examples. I want to like the ClientFactory concept. But here's…
user1768830
6
votes
2 answers

Poltergeist antipattern example

I'm trying to understand what is Poltergeist antipattern, and how does it differ from Command or Delegate patterns. I've read: http://en.wikipedia.org/wiki/Poltergeist_(computer_science) http://sourcemaking.com/antipatterns/poltergeists But didn't…
Oleg Oshkoderov
  • 500
  • 1
  • 4
  • 17
6
votes
4 answers

Which is more evil: an unnecessary singleton or a God Object?

Here's the situation: I've got a class that is doing too much. It's mainly for accessing configuration information, but it also has the database connection. It's implemented as a singleton, so this also makes unit testing it difficult as most…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
6
votes
9 answers

Are there valid reasons to hold data internally as XML?

In the years that I've been at my place of employment, I've noticed a distinct trend towards something that I consider an anti-pattern: Maintaining internal data as big strings of XML. I've seen this done a number of different ways, though the two…
Greg D
  • 43,259
  • 14
  • 84
  • 117
5
votes
5 answers

Where do new methods go?

Let's say I have an object, Car, and it has sets of methods that are... disparate? Maybe getting Blob-like? (as in the antipattern, "blob") These methods operate in distinct enough sets and don't really criss-cross functionally. Car # methods…
Mark Canlas
  • 9,385
  • 5
  • 41
  • 63
5
votes
2 answers

Is it an anti-pattern to put labels and such in property files (releated to JSP's and web development)

I see a lot of J2EE developers put labels in property files but don't use different Locales. So, you get a lot of missing property exceptions. And the main thing is that it makes it hard to debug and read a JSP page. So over time, you have…
Berlin Brown
  • 11,504
  • 37
  • 135
  • 203
5
votes
3 answers

is there any good source of anti-patterns?

I've heard and read many materials for design patterns, coding styles, programming techniques, etc... but seldom read anti-patterns materials. I think reading those materials can learn a lesson in a "negative" way, such that it's meaningful for…
wala
  • 118
  • 1
  • 5
5
votes
3 answers

When to separate code into new assemblies (DLL's)

I work as part of a team creating an enterprise application that will be used in a new C# .NET Windows Application and a Web Application of the same. One of the other developers likes to separate things out into separate projects a bit more than I.…
Neal
  • 9,487
  • 15
  • 58
  • 101
5
votes
2 answers

"messy-polymorphism" anti-pattern

In fairly large Ruby application, we have a situation where a given object is identified by a couple of things: name and id, say. Each of these value types serves a somewhat different purpose and so are not exactly equivalent (id and name persist in…
Joe Soul-bringer
  • 3,294
  • 5
  • 31
  • 37
5
votes
13 answers

What is the name of this anti-pattern?

Surely some of you have dealt with this one. It tends to happen when programmers get a bit too taken by OO and forget about performance and having a database. For an example, lets say we have an Email table and they need to be sent by this program.…
WW.
  • 23,793
  • 13
  • 94
  • 121
5
votes
2 answers

Is extending a widget really an antipattern?

I've read in couple places that extending a Flutter widget is an anti-pattern. Is that true? I've used widget subclassing to cut down on nesting by subclassing the widget I'm removing and put its widgets in its constructor, like so class Foo extends…
buttonsrtoys
  • 2,359
  • 3
  • 32
  • 52
5
votes
1 answer

In JavaScript, is `return someValue` in a generator function an anti-pattern?

In the following, the .next() can show the last value: { value: 3, done: true }: function* genFn() { yield 1; yield 2; return 3; } const iter = genFn(); console.log(iter.next()); console.log(iter.next()); console.log(iter.next()); But not…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
5
votes
6 answers

What anti patterns do you use even though you know you shouldn't?

Am I the only one that sometimes take the seemingly easy, but wrong, way out of certain design situations? I'll admit I've made my share of questionable Singleton objects. Besides that, I've been known to make a God object or two to make things seem…
Per Stilling
  • 868
  • 2
  • 9
  • 19
5
votes
3 answers

Is having a ubiquitous base object an anti pattern?

I remember seeing a debate about this somewhere, and am currently considering removing a base object that every business object, in a system I'm working on, inherits from. It contains a few properties, some database logic, and some constructor…
johnc
  • 39,385
  • 37
  • 101
  • 139
5
votes
6 answers

AntFarm anti-pattern -- strategies to avoid, antidotes to help heal from

I'm working on a 10 page web site with a database back-end. There are 500+ objects in use, trying to implement the MVP pattern in ASP.Net. I'm tracing the code-execution from a single-page, my finger has been on F-11 in Visual Studio for about 40…
alchemical
  • 13,559
  • 23
  • 83
  • 110