What do you do with atrocious code?

refactoring

Solution

Depends on a few factors for me:

- Will I be maintaining this code in the future, or is it a one-off fix?

- How long until this system is replaced entirely?

- How busy am I at the moment?

Ideally, I'd refactor all bad code I had to maintain, but the reality is there are only so many hours in the day.

Problem

What do you do when you're assigned to work on code that's atrocious and antiquated to the point where it's almost incomprehensible? For example: hardware interface code, mixed with logic, AND user interface code, ALL in the same functions? We see bad code all the time, but what do you actually do about it? - Do you try to refactor it? - Try to make it OO if it's not? - Or do you try to make some sense of it, make the necessary changes and move on?

Original source

Related problems