Boolean/enum parameters

This follows my post on unnecessary if statements, and broaches a bigger evil. As Uncle Bob says at the end of this article: “Boolean arguments loudly declare that the function does more than one thing. They are confusing and should be eliminated.” Same verdict should apply for an enum as a method parameter.

Continue reading

Advertisements

Ifs (Booleans and enums)

I am almost always dismayed when I see a method with too many if statements. More often than not, this is a precursor to similar conditions in other methods in the same or other classes, using the same condition to switch the actions to be called. This is an anti pattern I’ve seen repeated at far too many places. I think the¬†anti if campaign¬†mirrors my thought process about what needs to be done. Continue reading