An anti-pattern is a behavior or practice that is common despite being ineffective or counterproductive.
25
votes
6answers
1k 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 ...
21
votes
8answers
3k views
Is it an antipattern, modifying an incoming parameter? [on hold]
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 ...
33
votes
10answers
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
249 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
148 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
107 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
495 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
49 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 ...
19
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 ...
1
vote
3answers
229 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
208 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 ...
5
votes
4answers
322 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
577 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
298 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
233 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
232 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
95 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
439 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
205 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
195 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 ...
4
votes
8answers
632 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
520 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
203 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
738 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
110 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 ...
1
vote
1answer
72 views
using business object as a key in a dictionary [closed]
I keep seeing it all over the place. I think it is an anti-pattern, it requires partially instantiated business object to be able to find the full one in a dictionary. Am I correct? Why would people ...
2
votes
1answer
234 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
549 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
288 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
505 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 ...
11
votes
5answers
4k 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
835 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
71 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 ...
45
votes
3answers
2k 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 ...
26
votes
13answers
3k views
Is there an antipattern to describe this method of coding?
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
890 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
193 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
340 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 ...
64
votes
14answers
4k views
Name for this antipattern? Fields as local variables
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();
...
2
votes
2answers
284 views
What's the name of this pattern involving multiple inputs and what to do based on an input?
If I've got code similar to this (although perhaps not as constrained as warning levels):
switch(item.StatusCode)
{
case StatusCode.SUCCESS:
CallSuccess(item);
break;
case ...
3
votes
2answers
739 views
God Files versus Ravioli Code
Recently I asked a question about whether or not I should refactor my code. the responses I received were most definitely in the camp of going through with the refactoring due to the presence of a God ...
1
vote
1answer
725 views
Modular Database Structures
I have been examining the code base we use in work and I am worried about the size the packages have grown to. The actual code is modular, procedures have been broken down into small functional (and ...
20
votes
9answers
4k views
Alternatives to the singleton pattern
I have read different opinions about the singleton pattern.
Some maintain that it should be avoided at all costs and others
that it can be be useful in certain situations.
One situation in which I ...
23
votes
7answers
4k views
Are utility classes with nothing but static members an anti-pattern in C++?
The question Where should I put functions that are not related to a class has sparked some debate over whether it makes sense in C++ to combine utility functions in a class or just have them exist as ...
7
votes
5answers
427 views
Reengineering the project from scratch [duplicate]
Possible Duplicate:
When do you rebuild an application or keep on fixing the existing one
I am currently working on a project that has been in development for the last few years used ...