Comment by JoeAltmaier
5 years ago
That is a win for everybody!
My similar story was removing a 10,000 line module that built hundreds of different packets for sending over a mailbox to a wifi module. Each method was almost identical, with the exception of building a slightly different header.
I replaced it with a template that given the structure, built a packet to send it. Less than 1 page of code.
Wow, that almost makes it sound like the original author was getting paid per line.
Must have. It was a new version of an old driver. The old driver was 9 modules. The new one - 900. Every tiny little thing was another module. It conversed in 802.11 and ethernet etc, so of course it had three (3) copies of non-compatible packet layout declarations, each comprising dozens of modules. And on and on.
It was like a computer science geek gone mad had figured, "I'll use every decomposition technique I ever heard of, and invent some more, so this is the most computer-sciencey source base in the world".
Ultimately I rewrote it in 12 C++ base classes and a derived object for each radio card I had to work with.