5 ms·
I agree with SwellJoe, gruseom and gasull: this is a code maintenance issue, and the way to sell it to the customer (and to yourself, so you can get started) is
by etal 18y ago
I agree with SwellJoe, gruseom and gasull: this is a code maintenance issue, and the way to sell it to the customer (and to yourself, so you can get started) is bundling some cleanup with each feature.
I ran into some ancient and crufty code at my last job, and learned some things in the process of dealing with it.
1. Make sure you're using sane version control -- SVN or a DVCS. If you're on a Unix or have access to cygwin, getting started looks like:
cd ~/projects/bigco/thisone
git init
git add .
git commit
This will give you the courage and safety net to make big changes to your code.
2. Look at your build file (Makefile?) and see what it says about the project's organization. You probably have some idea of what's wrong already, but this might point out things like files that are never compiled, the same few files used to build everything else -- even though one or more files really should only do one specific thing.
3. Start cutting dependencies. Starting with the file where you're adding the newest feature, look into each of the files/modules included/imported and see if the dependency is really necessary. Maybe you only depend on one function or data definition in that other file, and it would make sense to merge that code with another existing dependency. Also take a hard look at your "utils" file/folder (every project has one) and see if some parts can be merged elsewhere, or even eliminated by using existing features of your platform.
4. Clean up the configuration file. Are some options irrelevant now? Are the defaults sane? Look at the code that touches it. Are there more defaults hidden in the code, when it should all be in the config file? Are there settings at the top of some files that could be moved to the config file? Don't go overboard, though: you usually don't need a configuration option to tell one piece of code about a choice you made in another piece of code in the same project. Clean that up, delete some if/else branches, and maybe find and clear some obsolete code in the process.
Also, we might be able to give more specific tips if you tell us more about the platform you're using. If the project is compiled, static analysis tools are worth a shot. If you're on Unix/Linux, it can be useful to break off pieces of code into standalone scripts, or better, use an existing (but perhaps obscure) command-line utility to replace old code or base a new feature on. Maybe use cron instead of your homespun scheduling system to launch these separate processes. But at least the customer is supporting this effort, right?