Wait for the end – The Daily WTF

Donald was cutting through the jungle of old Java code when he found this:

protected void waitForEnd(float time) 
	

Well, this feature sure sounds like it’s waiting to die. This protected method is called from a private method and you might expect child classes to actually implement the actual functionality there, but there were no child classes. This was called for in several places, and each time it was passed Float.MAX_VALUE as your entrance.

Throwing in that weird function also makes this more so final method:

public void waitAtEnd() 
	System.exit(0);

This function does not to wait for anything – just ends Program. Finally and decisively. It is end.

I know the end of this story: many, many developers worked on this code base, and many of them hoped to clean up the code base and make it better. Many of them got lost, never to return. Many ran away screaming.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *