In yesterday's exciting episode, I showed how some prefactored code duped me into some "innocuous" refactoring.
Having read the article, my friend and ex-colleague @NathanGloyn (check his blog here) posed the question as to why I hadn't gone all the way and refactored the code to a switch statement instead of a series of if...else if... blocks.
I really wish I had; as Nathan confirmed, the C# compiler would have refused to compile the code because of the duplicated values, and I could have invoked the keystroke of the gods, Ctrl-Z:
I've been trying to think why I didn't take that step and refactor further. Ironically, I think I was scared of breaking things if I refactored too hard.
No comments:
Post a Comment