This is a good question that is relevant to the systems engineering development life cycle. However, I feel the duplicate candidate adequately answers it, so it should remain closed as a duplicate.
The original question states:
I happen to want to make some enhancements in a still-functional code
that was written a long time ago, before the programming language it
is written in grew in features. In theory, the whole project uses the
up-to-day version of the language, however this particular module (and
in fact, many other modules) are still written in the older dialect.
The crux of the issue is "this is old code that works, but is written in a different way than other modules."
From the accepted answer at the dupe target:
Quick Tips for Good House-Keeping
- When in hotfix-mode, based on a customer support request:
- It's usually a best practice to NOT go around fixing other issues, as you
might introduce new ones unwillingly.
- Go at it SEAL-style: get in, kill the bug, get out, and ship your patch. It's a surgical and tactical strike.
- But for all other cases, if you open a file, make it your duty to:
- definitely: review it (take notes, file issue reports),
- maybe: clean it (style cleanups and minor violations),
- ideally: refactor it (reorganize large sections and their neigbors).
This is a checklist of approaches to take when editing old code. Specifically, the "all other cases" section answers the original question by saying, paraphrased, "go ahead and clean it up as time permits, and use official review channels (put it in a bug tracker, for example) to track what you are doing and what might need regression testing."
I get it that the dupe-target answer is huge. It is super-long and includes information that is not relevant here. However, it does contain an answer to the question, which should remain closed as a duplicate.