Thursday, February 24, 2005

Suicidal code

Have you seen code that's so bad if it had any feeling it would trigger an EMP next to the source control server to commit suicide? Well, I have. And here is an example:

public synchronized void invoke(AbstractCommand command)
{
if (command == null) return;
remoteDoIt(command);
if (command instanceof Undo)
{
undo();
return;
}
if (command instanceof Redo)
{
redo();
return;
}
if (command instanceof Update)
{
command.doIt();
return;
}
if (command.doIt())
{
history.addLast(command);

if (redo.size() > 0)
{
redo.clear();
}
}
else
{
history.clear();
updates.clear();
}
}
To make matters worse, Undo, Redo and Update are all empty "marker" interfaces. Refactor this!

2 Comments:

Anonymous Anonymous said...

"EMP next to the source control server", LOL, that's funny!

3:47 PM  
Anonymous Anonymous said...

Try thedailywtf.com

4:29 PM  

Post a Comment

<< Home