3 ms·
Sorry I answered as a top level comment. Im on my phone
by d--b 8y ago
Sorry I answered as a top level comment. Im on my phone
- meheleventyone 8y agoNo problem! It seems that the issue is less that the code is made more opaque but that you can quickly think of some counter-examples or nitpicks that make the advice less valid to you? I think the problem of not being universal is true of most programming advice. So I don't necessarily see it as a reason to discount it. I also think in contrast to a lot of articles the author has done a great job to couch their advice as being contextual. For example for your criticism of Pattern 4 the author does actually point out the obvious solution to these complex expressions. To split them out into several parts. Which is what you get with if statements to an extent but spread out much more with a lot of clutter. Some of your criticism also seems to be based on a misreading of the authors intent. For example Pattern 5 where the goal isn't to remove the if statement but prevent having to repeat the same error checking pattern everywhere.
- d--b 8y agoWell despite a few sentences like “remember, if statements are not all bad”, the author still makes a case that if statements are generally to be avoided. My point is that this in itself is bad advice. Overuse of oop concepts is just as harmful (if not more) as overuse of if statements.
- meheleventyone 8y agoOveruse of anything is generally harmful (since it suggests doing too much of it) otherwise it would just be use! But I'm fairly convinced the author isn't saying that they are to be generally avoided, to quote directly: > If statements usually make your code more complicated. But we don’t want to outright ban them. I’ve seen some pretty heinous code created with the goal of removing all traces of if statements. We want to avoid falling into that trap.
- hellofunk 8y ago> Overuse of oop concepts is just as harmful The author's examples are not all about oop -- many of them having nothing to do with oop, they are just good advice for clean code in general.