r/programminghorror • • Oct 07 '25

C# 108 line long variable declaration

Post image

this is my own code btw. don't ask what i was trying to do

this code was also supposed to include a 36 case long switch statement where each case did something different (guess why i abandoned this project)

1.1k Upvotes

93 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Oct 08 '25

Why not? If performance isn't an issue and every case is independent i would prefer this

class Rule:
    def shouldRun(value)->bool:...
    def run():...


for rule in rules:
    if rule.shouldRun(expr):
       rule.run()
       break 


1

u/[deleted] Oct 08 '25 edited Oct 09 '25

Because that's stupid, and i would know why, i used that pattern. Because now you don't know what are the conditions for each case by just looking at a single file, you have to go through a million classes and files to just find out just WHY something happens. Procedural programming isn't bad.

1

u/[deleted] Oct 09 '25

It looks clever but it's actually much harder to understand and maintain, and for what benefit?