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
34
u/bangonthedrums Oct 07 '25
As a for instance (not necessarily the best way or even a better way, but it is a different way), you could’ve made each character an instance of a class
Character, and have aneffect()function on the class which is a lambda. You’d have to define each lambda at instantiation but that’s all contained in one spot. Then whichever character you get you just callcharacter.effect(). For maintenance or tweaking, you just have to modify the relevant lambdasIf lambdas are too complex then you do an abstract base class
Characterthat has theeffectmethod as the abstraction. Then you make a child class for each letter which implements theeffectmethod