4 ms·
The Anti-If Campaign
- scott_s 17y agoOddly named campaign to promote better use of inheritance. "The Anti-Type Fields Campaign" would be more appropriate and less confusing.
- henning 17y agoInheritance or polymorphism?
- tptacek 17y agoIt's not about type fields and tag-and-switch. It's about the "if" statement. Let's be clear about how batsh*t crazy this messaging is.
- scott_s 17y agoIf you read their content (what little there is), it's type fields that they actually object against. I don't think they're actually saying "remove all ifs from code." If they are, then, yes, that would be batshit crazy. Instead of being crazy, though, I think they're just ineffective at communicating their message.
- tptacek 17y agoI agree with you: it's the messaging that's batsh*t crazy, not the idea. The idea is just bad.
- davidw 17y agoWith pattern matching, you actually end up being able to mostly do away with if and switch statements, so it's not completely as crazy as it sounds. OTOH, sometimes pattern matching involves a lot of "repeating yourself", where you have to retype the function name, and a bunch of arguments, and only one changes.
- calambrac 17y agoDon't solve with conditionals that which can be solved by your language's dispatch mechanism.
- tptacek 17y agoDon't solve with 15 minutes that which you can bill your client 80 hours for.
- stcredzero 17y agoAnd don't forget, lots of those 15 minute intervals can add up to serious money. ("Stovepipe" systems.) You can also set up an opportunity to bill for coming later in and "fixing" a seemingly intractable big mess.
- Confusion 17y agoDo not attribute to malice what can be equally well explained by stupidity.
- stcredzero 17y agoMalice has a better chance of sustained profitability. EDIT: This is a clue to bad intent. "Follow the money!"
- stavrianos 17y agoand yet, the world over, people are still both basically decent and basically stupid. Edit: correlation?
- tptacek 17y ago"Oh, I see the problem right here, Mr. Client. Your previous consultant used 'if' statements. Here, let me replace that function with 80 new class files. You'll be much more agile!"
- deleted 17y ago[deleted]
- J_McQuade 17y agoThis sort of debate annoys me - not so much because of the potentially fragile design on one side or the perhaps pedantic adherence to OOP principles on the other, but because I know that I could have things like pattern matching and a scarily expressive type system and, well, that'd make a lot of these problems disappear. Curse you, Haskell, for making me so bitter!
- tptacek 17y agoThis is a joke, right? They're making fun of all the programs you see that have 20 different forests of tiny classes spreading the logic of one function across 45 files, right?
- erlanger 17y agoYou mean Lussumo?
- aheilbut 17y agoafter vanquishing all if statements, we're going to go after function calls. And after that, we will eliminate source code, because it's too complicated. Everything you need to do can be done with 5x7 index cards.
- tptacek 17y agoFirst they came for the function definitions, and I said nothing, for I used lambdas.
- jrandom 17y agoThis strikes me as particularly funny as I'm working on a module of code where I had to use a type field and an 'if' statement to get around a dynamic cast that was killing performance. (Virtual functions were not an option as this was taking place inside an STL '==' comparator.)
- wglb 17y agoThese days, I tend to use COND rather than IF. Ah, but the page implies use bunches of teeny classes. Was that what Alan Kay had in mind when he coined "Object Oriented Programming"?
- gabeybaby 17y agoI think this "campaign" is aimed at a developer less capable than the crowd we see on HN. I used to work with a whole team of people where OOP is a strange concept. I think the Anti-IF rule can help people think in a more correct fashion if they're confused about Inheritance.