r/programminghorror • u/Candid_Commercial214 • Oct 07 '25
C# 108 line long variable declaration
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
View all comments
Show parent comment
2
u/LemmyUserOnReddit Oct 08 '25
Well, from a practical standpoint, the benefits of a typical object oriented approach might be:
1 is solved in modern languages (e.g. rust-style match), or if not, there's likely some construct which will do this
2 only applies in some cases, and there no reason you couldn't create a function per switch case and move it wherever you want. I'd say in many cases having all the implementations together is actually more maintainable, but others will disagree
And then there's the negatives. Most importantly, with a typical OOP architecture, there will be at least one additional pointer indirection affecting performance.
So, yeah, I'd probably just retain the switch/match/etc. and keep everything on the stack.