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

learn more… | top users | synonyms

36
votes
9answers
5k views

Is creating subclasses for specific instances a bad practice?

Consider the following design public class Person { public virtual string Name { get; } public Person (string name) { this.Name = name; } } public class Karl : Person { ...
1
vote
2answers
119 views

Why do IoC containers provide public Resolve method(s)?

In my opinion it just inverses the inversion and could make new users (including myself) make incorrect assumptions about using IoC containers. It can be used for the Service Locator (anti-)pattern ...
6
votes
2answers
455 views

Which is a better pattern (coding style) for validating arguments - hurdle (barrier) or fence? [duplicate]

I don't know if there are any accepted names for these patterns (or anti-patterns), but I like to call them what I call them here. Actually, that would be Question 1: What are accepted names for these ...
1
vote
2answers
150 views

Is it an anti-pattern to use void* and enums to enable type-checking?

Say in a game engine, you have Objects that composited of different components. One of these is a RenderComponent which can be either a Mesh, a Sprite or a Light. Now, all these are vastly different ...
-4
votes
2answers
195 views

Is this a poltergeist or is it justified? [closed]

I've come to a point in re-design of my code where I face an imminent Poltergeist Anti-Pattern threat. A master application object has two "eye" objects. Eye objects have a "RenderHUD" function, which ...
2
votes
0answers
226 views

Is there a name for this anti-pattern? (Variable has context-dependent meaning) [closed]

I'm working on a legacy system with troubling behavior - it uses the same identifiers to signify different things in different places. The system in question is a CRM system. It uses special codes ...
1
vote
1answer
47 views

How do you wrestle the DRY principle with configs?

For instance, lets say we have an nginx config pointing at foo1, foo2, and foo3, as well as a haproxy config pointing at foo1, foo2, and foo3, and finally, a deployment tool pointing at the same ...
33
votes
6answers
2k views

Good or bad practice to mask Java collections with meaningful class names?

Lately I've been in the habit of "masking" Java collections with human-friendly class names. Some simple examples: // Facade class that makes code more readable and understandable. public class ...
22
votes
8answers
3k views

Is it an antipattern, modifying an incoming parameter? [closed]

I am programming in Java, and I always make converters sort of like this: public OtherObject MyObject2OtherObject(MyObject mo){ ... Do the conversion return otherObject; } At the new ...
35
votes
11answers
4k views

Are error variables an anti-pattern or good design?

In order to handle several possible errors that shouldn't halt execution, I have an error variable that clients can check and use to throw exceptions. Is this an Anti-Pattern? Is there a better way to ...
5
votes
4answers
290 views

Direct database manipulation an anti-pattern?

Recently I learned that some teams have moved all their database manipulation to the actual database through the use of stored procedures. I thought that was pretty clever, since the database becomes ...
0
votes
0answers
425 views

Spring bean injection into a hibernate validator constraint

I have a controller method like listed below whose argument is annotated with @Valid to validate PasswordChange object using a Hibernate validator @Constraint. Both PasswordChange and a sample ...
-2
votes
1answer
112 views

Is there a named antipattern for unclear API not exposing the requirements? [closed]

In the source code I'm evaluating (jarjar), there exists java code that can be used like this: JarJarTask fixture = new JarJarTask(); fixture.addConfiguredRule(new Rule()); fixture.execute(); Which ...
0
votes
3answers
660 views

How can I explain this is an anti-pattern? [closed]

I recently started at a new job. The existing system works OK but is poorly designed and hard to maintain, and they are planning to rebuild it in MVC and I fear it will be much worse. (Not because ...
0
votes
1answer
61 views

Inverse of Extract Interface refactoring

I'm working with a Java project that has several interfaces, many of which have only one implementation. (See related question) For a given revision of the software, one could think this acceptable ...
23
votes
2answers
1k views

Is there an anti pattern for historically grown software? [closed]

Is there an anti pattern that describes a historically grown software system where multiple developers just added new features to the system but no one really kept an eye on the overall architecture ...
2
votes
3answers
358 views

Global request context - anti-pattern?

I was talking today to a colleague of mine about Python web frameworks and our impressions about them. I told him I think Flask having a global request smells badly and is an anti-pattern. The docs ...
14
votes
7answers
1k views

Should I refactor large functions that mostly consist of one regex? [closed]

I just wrote a function that spans approximately 100 lines. Hearing that, you are probably tempted to tell me about single responsibilities and urge me to refactor. This is my gut instinct as well, ...
7
votes
2answers
241 views

To load or not to load data for unit tests from external files

When unit testing I often find myself debating how much of the data I feed to, and expect back from my units under test, I should include in the actual test files. The tradeoff I constantly ...
6
votes
4answers
340 views

Preventing a parser from turning into a (seemingly) god-sized object

So I have a program whose purpose is to take text files and parse them into a binary format that an embedded system understands. However, the text format I've inherited that I need to parse is ...
25
votes
2answers
2k views

What is the name of the following (anti) pattern? What are its advantages and disadvantages?

Over the last few months, I stumbled a few times over the following technique / pattern. However, I can't seem to find a specific name, nor am I a 100% sure about all its advantages and disadvantages. ...
6
votes
4answers
586 views

Structured code vs Duplicate code. Modifiability [duplicate]

I have noticed that my classmates write unstructured code with a lot of duplication. And their solutions of the same tasks often contains more then three times more lines than my project. But when ...
-1
votes
1answer
344 views

Are verb-like classes a code smell? [closed]

I do a lot of flat-file processing to extract data. The file "formats" are very unique and each file format requires a lot of format-specific code. Sometimes, the parsing code needs to maintain a lot ...
2
votes
0answers
249 views

Is this any form of service pattern, some other pattern, SOA or just an anti-pattern?

I'm going to set out a scenario/pattern I've encountered and then I have a few questions pertaining to it. During an MVC request in a web framework (PHP, Laravel in my case), if I have an abstract ...
4
votes
2answers
251 views

If an entity is composed, is it still a god object?

I am working on a system to configure hardware. Unfortunately, there is tons of variety in the hardware, which means there's a wide variety of capabilities and configurations depending on what ...
1
vote
1answer
103 views

How to Avoid a Busy Loop Inside a Function That Returns the Object That's Being Waited For

I have a function which has the same interface as Python's input builtin, but it works in a client-server environment. When it's called, the function, which runs in the server, sends a message to the ...
8
votes
2answers
471 views

Is implementing an interface defined in a subpackage an anti-pattern?

Let's say I have the following: package me.my.pkg; public interface Something { /* ... couple of methods go here ... */ } and: package me.my; import me.my.pkg.Something; public class SomeClass ...
1
vote
1answer
214 views

Unit-testing databases: test all possible permutations of read and write to table?

I am testing a resource management class that is interacting with a database or a file system, or a combination of both. I was wandering if it is the norm to test all possible permutations of read and ...
5
votes
1answer
203 views

Looking for a book, blog or feed about anti-patterns [closed]

In my experience, being familiar with anti-patterns is as vital as knowing patterns themselves. Despite an abundance of literature on patterns, there is a surprising lack of literature on ...
5
votes
8answers
848 views

Passing an object into a method which changes the object, is it a common (anti-) pattern?

I am reading about common code smells in Martin Fowler's Refactoring book. In that context, I was wondering about a pattern I am seeing in a code base, and wether one could objectively consider it an ...
2
votes
2answers
538 views

What is this (anti?)pattern called? (or how to describe it)

The case where a source-level operator actually describes an operation to take place at some future point, thunking the real operator together with its operands. I don't know if this has any kind of ...
4
votes
1answer
211 views

Reference Passing Style Anti Pattern

I'm working on a legacy VB.Net code base. There are very few functions that return values, most of the code is in subs/void methods. The general strategy seems to be to pass everything in by ...
10
votes
3answers
969 views

How to tackle a 'branched' arrow head anti-pattern? [duplicate]

I recently read this question that features, the arrow anti-pattern. I have something similar in code I'm trying to refactor except that it branches. It looks a little something like this: ...
2
votes
0answers
111 views

How to restructure Python frameworks [duplicate]

I just joined a group of five developers (non-professionals) working on a medium sized Python framework (> 50 modules, > 10.000 lines of code). The project has no documentation whatsoever and there ...
3
votes
1answer
239 views

Established antipattern name? Only getting data ducks in a row right before you need them

This one's all over our codebase but I'm not sure I've ever heard a name put to it. We have C# and Java (and Rails but we don't have to touch it very often) so I'll speak more generally. It's like ...
7
votes
3answers
613 views

TDD Mock call verification - is it an anti-pattern?

I've been doing TDD for year now, I feel pretty good about it, I love my test suites and all. However I've noticed that lately I've been doing a lot of mock call verification. For example I'd have a ...
3
votes
5answers
306 views

Avoiding the Anaemic Domain - How to decide what single responsibility a class has

Even after reading a bunch I'm still falling into the same trap. I have a class, usually an enity. I need to implement more than one, similar operations on this type. It feels wrong to (seemingly ...
45
votes
19answers
3k views

Forcing people to read and understand code instead of using comments, function summaries and debuggers? [duplicate]

I am a young programmer (finished computer science university but still under a year of working in the industry) and I recently got a job working on some C code for a decent size web service. Looking ...
3
votes
4answers
515 views

Are Compiler Directives an Antipattern?

I'm working on a legacy system that has a helper class that is symbolically linked into many different .Net projects within a solution. The logic is riddled with compiler directives that change it's ...
15
votes
7answers
5k views

Are exceptions as control flow considered a serious antipattern? If so, Why?

Back in the late 90's I worked quite a bit with a code base that used exceptions as flow control. It implemented a finite state machine to drive telephony applications. Lately I am reminded of those ...
0
votes
1answer
1k views

Code reuse via inheritance [duplicate]

I have a set of classes that are all dealing with some related tasks. These tasks do have different inputs and outputs. This causes it to become impossible to have the tasks done via shared code ...
4
votes
1answer
216 views

Where and when to include assets in languages that don't care where they are declared?

I come from c++, where one declares all assets to be included at the top of a file. That is what I have been doing with php as well. Lately I have been tempted to stray from this rule: I have a script ...
0
votes
1answer
72 views

terminology for upward devolution from modules to framework

Is there a word for the problem of a framework becoming married to the software modules it supports, for example adding methods to a base class that may apply only to certain subclasses or use cases? ...
10
votes
7answers
2k views

Is this “anti-pattern” and should I stop using it or is this clever design?

I've basically stared to do the following when creating a REST service: HTML is requested service returns the desired web page but without the requested "resource", eg. data web page contains ...
46
votes
3answers
3k views

Is jQuery an example of “god object” antipattern?

I want to ask – I am slowly learning jQuery. What I see is an exact example of a God Object anti-pattern. Basically, everything goes to the $ function, whatever it is. Am I right and is jQuery ...
25
votes
13answers
3k views

Is there an antipattern to describe this method of coding? [closed]

I have a codebase where the programmer tended to wrap things up in areas that don't make sense. For example, given an Error log we have you can log via ErrorLog.Log(ex, "friendly message"); He ...
3
votes
2answers
1k views

Alternative to “inheritance versus composition?” [duplicate]

Possible Duplicate: Where does this concept of “favor composition over inheritance” come from? I have colleagues at work who claim that "Inheritance is an anti-pattern" and want to use ...
2
votes
1answer
194 views

Use of interfaces to ease rapid development/prototypes

Recently I've started to put almost all of my data structures into interfaces, and many of the classes that contain pieces of logic code as well, depending on how much work they are. I find that this ...
2
votes
3answers
374 views

Dynamic Forms: Pattern or AntiPattern?

I'm sure you've seen it. The database has a bunch of tables called Forms, Controls,FormsControls, ControlSets, Actions and the program that queries these tables has a dynamically generated user ...
63
votes
14answers
4k views

Name for this antipattern? Fields as local variables [closed]

In some code I'm reviewing, I'm seeing stuff that's the moral equivalent of the following: public class Foo { private Bar bar; public MethodA() { bar = new Bar(); ...