anti-patterns

Avoiding parallel inheritance hierarchies

I have two parallel inheritance chains: Vehicle <- Car <- Truck <- etc. VehicleXMLFormatter <- CarXMLFormatter <- TruckXMLFormatter <- etc. My experience has been that parallel inheritance hierarchies can become a maintenance headache as they grow. How do I avoid a parallel inheritance hierarchy without b...

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. At start-up, it looks for anything that needs to be sent as follows: Emails = find_eve...

"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 different places). So we wind-up with a variety of values being passed around the applica...

Can a C# property accept multiple values?

This might be a bit of an anti-pattern, but it is possible for a property on a C# class to accept multiple values? For example, say I have an Public int property and I always want it to return an int, but I would like to be able to have the property set by assigning a decimal, an integer or some other data type. So my question is if it ...

Secret Handshake Anti-Pattern

I've just come across a pattern I've seen before, and wanted to get opinions on it. The code in question involves an interface like this: public interface MyCrazyAnalyzer { public void setOptions(AnalyzerOptions options); public void setText(String text); public void initialize(); public int getOccurances(String query); ...

What are the PHP-specific antipatterns that you know of?

PHP as a Blunt Instrument I hear PHP getting bashed around a lot lately. In quite a few projects, I have seen insane php code bases - so bad you really wonder if the person was on hallucinogenic drugs when they wrote the code. Sometimes, I wonder what the code would have been like if the initial developers had a bit more guidance as to ...

Common design by obfuscation practices?

What are some common practices you have seen used in the design by obfuscation crowd? I find it interesting to be on projects that are not allowed to be rewritten while, that would be the faster and most efficient solution to the problem. ...

High Availability and Disaster Recovery Software AntiPatterns

If you had to audit a Java application for worst-practices when it comes to high-availability and disaster recovery, you would probably look for hardcoded IP addresses and suboptimal caching of bind handles. What else should be considered? ...

What is soft coding? (Anti-pattern)

I found the Wikipedia entry on the soft coding anti-pattern terse and confusing. So what is soft coding? In what settings is it a bad practice (anti-pattern)? Also, when could it be considered beneficial, and if so, how should it be implemented? ...

When do you know you're dealing with an anti-pattern?

I'm looking to see how other programmers find anti-patterns, "code-smells", etc. In particular, what things start setting you off when you're looking at code that tells you, something has gone wrong here? I'm not looking for a list of different patterns like this post. I want to know how you've found such things in code bases you've...

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 thousands of lines of property files that may or may not be used with the JSP file. For me, it ...

Do these database design styles (or anti-pattern) have names?

Consider a database with tables Products and Employees. There is a new requirement to model current product managers, being the sole employee responsible for a product, noting that some products are simple or mature enough to require no product manager. That is, each product can have zero or one product manager. Approach 1: alter table ...

What is an Anti-Pattern?

Hi, I am Studying about Patterns and Anti-patterns . I have a clear idea about Patterns. but I am not getting Anti-Patterns. Web Definitions and Wikipedia is confusing me a lot. can anybody explain me in simple words that what is anti-pattern ? what is the purpose . what they do ? .. is it a bad thing or good thing ? ...

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 worst offenders were quite similar. The Webservice The first application, a web service...

Is INTERPRETER an anti-pattern?

To me, the Interpreter patten sounds very much like an anti-pattern known as Greenspun's tenth rule: Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. That is, if you need to use Interpreter, you're likely to create something that's sl...

How to overcome the anti-pattern "Big Ball of Mud"?

What causes a computer program to turn into a Big Ball of Mud? Is it possible to recover from this anti-pattern? Are there proven refactoring methods that can be applied? ...

How to avoid lots of parameters in critical methods of my applications?

Hi. I tend to sucessfully write compact applications that can encapsulate many business logic in a simple and non-redundant way. I tend to create small methods, but over time I arrive to methods that have too many parameters. I know every code requires its design, but I see and antipattern in my behaviour and I am not sure which would be...

Singleton with Arguments in Java

I was reading the Singleton article on Wikipedia and I came across this example: public class Singleton { // Private constructor prevents instantiation from other classes private Singleton() {} /** * SingletonHolder is loaded on the first execution of Singleton.getInstance() * or the first access to SingletonHold...

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 code is pretty tightly coupled to it. This is even more problematic as it creates an import-...

Is it in an anti-pattern to always use get and set methods to access a class's own member fields?

In Java classes is it considered good or bad practice to access member fields with their getters and setters? e.g which is better: public Order { private Agreement agreement; public Agreement getAgreement() { return agreement; } public void process() { //should I use: getAgreement().doSomething(); ...