News for hackers. Stuff that matters.
Re:Anti-if: The Missing Patterns by rtpg on Thursday June 09, 2016 @09:21PM (#11873659)
I think if your boolean is coming from user input then refactoring your method to accept user input, and then wrapping your method with a helper function that does the user input call would still be good advice.

At some point applying "anti-if" does involve major refactoring, so the outer style of your code might need to change a bit.

Of course like all design patterns it's more of a thought experiment than a total prescription IMO. But taking the thought experiment to its logical conclusion can also yield interesting results.

Some people might throw out strawman arguments about design patterns, but I'll end up reading the strawman and be like " yeah that does sound like a good idea". It's pretty hard to overestimate the value of regularity in code.

There are no comments on this comment yet.