I have always worked with the concept of what I call “trouble nodes.”
These are basically graph vertexes; places where two (or more) things interface.
Every “node” is a potential quality hit. A lot of my refactoring involves removing these, using techniques like deriving base classes, protocol defaults, or recursion/reuse.
As an example, a couple of days ago, I refactored an SDK I’m refining. It has an auth capability that uses an API key (bearer token), in a Basic Auth scheme. It does this via a common method that generates a URL request, and adds a header.
But servers that run fastCGI don’t like auth headers, so I was forced to add the option for query arguments to deliver the tokens.
So I basically “kludged” it, and added the arguments to the URI in all the places the requests were being built. An ugly, clumsy, lash-up (I was in a hurry).
This was months ago. I forgot I did that.
As I was reviewing my code a few days ago, I saw this, and was quite embarrassed.
Not only was it sloppy, but it was dangerous. This was auth stuff. The worst kind of place to have rotten quality code.
The refactoring was a pretty intense effort, and removed dozens of “trouble nodes.” It was fundamental stuff, and required a lot of testing. If I had taken the time to do it right, the first time, it would not have been necessary. I’m glad I found it before it became a problem.
And I slept like a baby, that night (waking up frequently, cying).