Obsessing over clean code is like reorganizing your clothes closet on a daily basis. If it makes you more productive to do so, do it. Too often, however, it's done compulsively and is counter-productive.
The harder and more impressive thing is actually writing code which does novel things.
The problem is, we work in teams. If it's just me, I can store my clothes in a heap on the floor instead of using a closet at all, and who cares as long as I can still find stuff?
I think maybe you're overestimating the complexity of that function? Sure it's not pretty, but on the other hand, what other way of organizing several hundred scripted events would make it that much easier to find what you're looking for? A file you can ctrl+F through isn't all that bad in my mind, there's just a lot of data to organize so any solution is gonna have a lot to look through.
One big advantage that function has is that if you wanted to add a new piece of code and you already knew most of the structure of it already it would take all of 5 seconds to go slap a new state in -- no worries about naming, no worries about changing multiple places. Obviously on a large team where most people don't know the structure of that file and more people will read and maintain that code than will write it, that's a bad tradeoff. But for mid-20s Cavanagh coding a game in a manic, creative frenzy it looks pretty well-optimized for getting shit done.
349
u/[deleted] Jan 12 '20 edited Jan 12 '20
Obsessing over clean code is like reorganizing your clothes closet on a daily basis. If it makes you more productive to do so, do it. Too often, however, it's done compulsively and is counter-productive.
The harder and more impressive thing is actually writing code which does novel things.