3 ms·
One of the most interesting experiences I had very early on in my career was reducing a 12,000 line C program to a roughly 1,000 line version (in C itself) with
by gjkood 11y ago
One of the most interesting experiences I had very early on in my career was reducing a 12,000 line C program to a roughly 1,000 line version (in C itself) without losing any functionality.
No, it had nothing to do with my prowess as a young coder, but solely due to the fact that my predecessor did not know what a function was nor how to use parameters.
He had written unrolled versions of the same piece of code, with embedded SQL with minor variations in WHERE CLAUSE values which could be easily parameterized.
All I had to do after analyzing the code was move the code into a function and loop through it with different parameters values.
Such is life.
- jgord 11y ago... I remember deleting ~500 C++ files .. they were all classes that differed by a constant, so I just passed in a parameter. Was not popular at all, they liked lots of files.
- 72deluxe 11y agoThat sounds stupid. Did they not know about inheritance or template classes or anything??
- jacquesm 11y agoI've had that exact same scenario about 4 years ago with a very large website (you've probably used them) which was put together in a hurry. The site was written in Java and each and every access to the database contained the exact same pre-amble, a bunch of database interaction with the aforementioned change to the where clause and then a cleanup section. Typically 50 to 100 lines. There must have been 100's of these copies in the code. In the end I moved the db open and close stuff to program startup and shutdown and replaced all the rest of it with a single function with a couple of parameters. The code suddenly became maintainable again.