This is *exactly* why I dislike working in bad code.
An old story:
I once had the job of re-implementing a program that loaded cryptographic keys in to EFTPOS terminals. The original program was dozens and dozens of pages of 132-column z-fold paper in FORTRAN from an old HP minicomputer that was being decomissioned. It was not modular. Loading such a key is basically a conversation and you have to tailor your responses according to a few possible states the device can report. Each send/receive sequence was a big block of code that did all the same work as every send/receive sequence. I was really not impressed with our EFT/ATM programmers after seeing that.
I developed a solution using a PC that had cryptographic hardware. Most of it was in C, but I also wrote a serial port driver in Assembly. Because of the nature of the actual key-loading, I also wrote a very simple language to describe the process (hand compiled into C macros :-). This enabled it to support *all* the different hardware, not just the one the original program did (there were other programs for the other hardware). The program also used things like function pointers and arrays of structures. Perfectly ordinary C-things, in other words.
The developer who got to maintain it encountered a bug with a terminal with new firmware: it's second-stage reset now took longer. *sigh* In trying to find the problem, he completely overlooked the finite state machine that was executing instructions and identified the problem as the wait-for-reply "statement". :-/ Clearly my efforts were way beyond anything he normally had to deal with.
More recently, developing an internet application in PHP, we hired some outsourced programmers for a few tasks. We were used to pushing what was possible in PHP. They were not. Their code came back as thousands of lines of code copied multiple times and modified slightly for each block. This was not acceptable: the rest of the codebase was fairly heavily modularised with several abstraction levels as we had demonstrably proven this gave us a leg-up in development and maintenance. We tried to get them to understand this. Several times. It was painful to see the ideas of "abstraction" and "modularity" simply fail to register in their minds.
We re-wrote their contribution to a tenth of the size. And it was faster and more versatile.
Wade.