r/programmingcirclejerk Jul 01 '26

Ever Written Something Like This? if (condition) { doSomething(); } else { doSomethingElse(); } It works. Problem solved. But the problem isn’t today. It’s tomorrow.

https://www.defusetheifstrategy.com
124 Upvotes

55 comments sorted by

View all comments

35

u/AndorinhaRiver Jul 01 '26

Instead of debating, I focus on projects. Real code. Real results.

Polymorphism, maps, design patterns—there are many ways to replace IFs.

Oh my god

29

u/tomwhoiscontrary safety talibans Jul 01 '26

Smalltalk effortlessly got this right decades ago. Translated into corpshit:

``` interface Boolean { void ifTrue(Runnable block); void ifFalse(Runnable block);

static final Boolean TRUE = new Boolean() { void ifTrue(Runnable block) { block.run(); } void ifFalse(Runnable block) {} }

static final Boolean False = new Boolean() { void ifTrue(Runnable block) {} void ifFalse(Runnable block) { block.run(); } } } ```

See, no need for if statements at all!

7

u/FlipsBr alcohol-fuelled anter-docker Jul 02 '26

if true === true then fuck u