in reply to Difficult code (Resolutions)
While there were a few cases where entire chunks of the app got ripped/replaced as they were too horribly broken to be fixed incrementally, my approach was mostly to fix *only* the piece that needed to changing (that piece, that whole piece, and mostly nothing but that piece). FWIW, I considered a piece to be a function, subroutine, and/or method.
For that piece,
1. First I'd fix the indenting/whitespace.
2. Then I'd pick a variable, figure out a better name and rename it-- I tended to search/replace one by one and checked how the variable was being used as I went. It was amazing how much dead code there was in the form of
declare $variable... set $variable... set $variable again... set $variable yet again... end of code piece-- value of $variable never used.
3. Repeated step 2 for all variables, removing dead sections and unused variables as they were found.
4. Ensured that the code still worked the same as before I started.
5. Refactored the piece if it made sense to do so.
6. Tested it again.
7. Made my change.
8. Tested it again.
Using this approach, I never rewrote the whole thing application, just the pieces that needed changes whether those changes were for bug fixes or new/different functionality.
Some observations that I made alng the way was that there tended to be a correlation between:
1. formatting and code quality (poor formatting ~ poor quality),
2. global variable useage and code quality (lot's of globals used ~ poor quality), and
3. unused variables and code quality (lot's of unused variables ~ poor quality).
my 2 cents.
The box said "Requires Windows 98 or better" so I installed Linux.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Difficult code (Resolutions)
by liz (Monsignor) on Aug 22, 2003 at 18:06 UTC | |
by gsiems (Deacon) on Aug 22, 2003 at 21:09 UTC |