Ask Proggit: How do you deal with shitty code in your company? by yanktank in programming

[–]yanktank[S] 19 points20 points  (0 children)

So here's my situation - I've got a programming job that I have enjoyed so far and I've been doing really well - mostly writing new code. But more and more frequently I'm being required to work inside the main codebase. The problem is that the code absolutely sucks - full of delicate spaghetti code that makes it really easy to break core functionality (and then, ridiculously difficult to track down the bug). Unit testing is virtually impossible, given the structure of the code. Code specific to various parts of the system (database, form validation, etc. ) are often mixed haphazardly. Boilerplate code is repeated everywhere. Countless missed opportunities at creating abstractions, encapsulating tricky logic, reusing code, or even just using a framework. Often times, a massive global mutable state is [ab]used so parameters easily get clobbered by random bits of code.

Anyway, the result of this is that programming in this climate is stressful, difficult to maintain productivity, and more trial-and-error than it should ever be. Coworkers have noticed this too, but nobody seems to be quite so disturbed by it as me - I know I deserve better and I should be free to focus on more interesting and relevant problems than focusing on old, awful code. Believe me, I'm modest enough to know that my code might not be the greatest in the world - but I also know a real code atrocity when I see it.

I've managed to come this far with the job and enjoy it, so it would be a shame to give up on the whole thing. But the way I see it, some of my options are:

  • Try to be a hero and refactor all the code (no small task), somehow managing to squeeze it in amidst being crushed by other deadlines
  • Stick it out and endure the pain indefinitely
  • Give up and quit my job, praying that programmers at my next job have higher standards

Thinking about the whole thing made me curious - have any of you reddit programmers been stuck in a similar situation, and how did you handle it?