News for hackers. Stuff that matters.
Re:Push ifs up and fors down by ilitirit on Thursday November 16, 2023 @12:39AM (#38286133)
I'm glad many people have identified why "pushing ifs up" is often bad advice. This article should give examples of when and why you should use both approaches. Furthermore, I would argue that there's far too little information and context presented here to even make a decision like that.What does `frobnicate` and `transmogrify` do? How many callers would need to perform these conditional checks? Do these if statements convey domain logic that should actually belong in the walrus class? If these checks need to be made often, would it make better sense to capture the call as a lambda and then only perform the check once instead of having a conditional for loop? Etc etc.

There are no comments on this comment yet.