11
kiki
4y

There was a task of fixing up a payments page that features pretty complex logic. Initially it was like 200 lines of code, seems short but it was a fucking spaghetti mess. Never seen more cognitively complex code in my life.

So I delete the spaghetti and pull out the 500 lines fucking state machine. It works perfectly. It’s perfectly understandable even though it’s longer.

This is how I deal with problems. Shorter code isn’t always better code.

Comments
  • 1
    200 lines but 2k cognitive complexity is never fun
  • 3
    The thing I see every Junior dev doing ever.
    “this code was too complex; it uses some useless shit like dependency injection”
    “I rewrote it with all static variables. Look how it’s easy now”
  • 0
    @NoToJavaScript there’s a difference between necessary and unnecessary complexity
  • 0
    I'm currently going through my company's Adam and Eve processes right now and every file is like that. I feel your pain brother. Spaghetti is tasty but I'll be damned if I want a nice juicy steak once in a while.
Add Comment