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

learn more… | top users | synonyms

0
votes
1answer
228 views

How could I avoid singletons in this case? [duplicate]

Using Dart in the client part of a web app where I have an application manager that contains a List of application instances and references to services that are used by each application as in the ...
0
votes
0answers
18 views

Is having a parent controller to manage a set of tabbed sections an anti-pattern for an angular application?

A lot of times, I have long forms that I divide into multiple tabbed sections. Each section is managed by it's own controller and there is a parent controller that manages the whole view. I use ...
11
votes
7answers
2k views

Name/Fix for Production Code Whose Sole Purpose is to Facilitate Testing? [duplicate]

The linked "duplicate" question is an iffy match at best, because it's asking is pattern X OK (YES/NO) and I'm clearly already in the NO camp, and subsequently asking what is pattern X called ...
0
votes
0answers
18 views

Where to override the design of jQuery UI elements?

We are using a few jQuery UI elements in our web application, and I need to change their design. For example, the ui-progressbar is way too high and its rounded corners don't fit well with our design. ...
0
votes
1answer
104 views

How can I avoid the “global $dbh” anti-pattern?

This is what most of my database-related library code looks like: lib.php <?php $dbh = new PDO(...); function doSomeDatabaseThing() { global $dbh; return $dbh->doStuff(); } function ...
7
votes
1answer
118 views

I'm being warned that the Monoid I'm creating is an Orphan Instance. Is there a better way to write this functionality in?

type PromptSegment = IO (Maybe String) instance Monoid a => Monoid (IO a) where mempty = return mempty mappend = liftA2 (<>) This behaves exactly how I want for my purposes. For ...
32
votes
6answers
6k views

Code that converts a value into a different representation, then converts it back to where it started is bad, but how? [closed]

I was reading an article about bad programming practices. It mentioned - "Yo-Yo code" that converts a value into a different representation, then converts it back to where it started (eg: ...
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
142 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
502 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
175 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
207 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
233 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
51 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 ...
34
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
4k 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 ...
36
votes
11answers
5k 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
318 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
599 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
113 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
775 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
64 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
456 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 ...
15
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
274 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
350 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
597 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
394 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
263 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
260 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
108 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
511 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
221 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
215 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
1k 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
552 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
217 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
1k 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
112 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
243 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
654 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 ...
4
votes
5answers
328 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 ...
4
votes
4answers
526 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 ...
17
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
73 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? ...