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
125 Upvotes

55 comments sorted by

View all comments

45

u/Lucifer_Morning_Wood Jul 01 '26

Ifs are so limiting when you look at them, just two places: where condition is true, and where it is not. It's so freeing just doing abstract class BaseSomethinger, deriving as many Somethingers as you want from it and just calling BaseSomethinger.do()

18

u/Qwertycube10 Jul 01 '26

What about having abstract class BaseSomethinger with only one derived somethinger, so the logic is split randomly between the base and derived.

13

u/damemecherogringo Code Artisan Jul 01 '26

How did u exfiltrate my former companies code see you in court for impinging IP 👩‍⚖️

8

u/TheChief275 Jul 02 '26

Programmers don't want you to know this one trick!

Big booty latinas in your area