When we last left our refactoring saga, I was regretting having done a State extraction too early, and was about to throw it out, doing some more class extractions first. Which is what I did, and it was clearly the right decision; I now have some significantly smaller classes, and they’re a lot easier to test. Not perfect yet: one, in particular, has a .cpp file with about 500 lines, which is larger than I’d like, and I’m not completely confident in my unit tests for that class. But it’s a significant improvement: one turning point is that the tests have been easier to write than I expected, rather than harder to write.

So yesterday, I tried again to do the State extraction. And, again, I’m going to throw that work away! But I’m definitely learning: this time, I only went two hours into the refactoring before throwing away my work, which is much better than throwing away three days of work. And, honestly, that two hours of refactoring was really useful, even though I’m throwing it away: maybe I could have noticed another class to extract without doing that speculative refactoring, but I wouldn’t count on it. Spending two hours and understanding my code better at the end of it sounds like a pretty good deal to me.

At this point, I am wondering if I will ever get to use State, though…

Post Revisions:

There are no revisions for this post.