Background
I’m a big believer in using refactoring tools to help improve the quality of the code I right. I just added another tool to my arsenal called CodeIt.Right from submain. I can’t say for sure whether the other tools commonly used will somehow perform the refactoring I’m going to show, but I can say I really like how CodeIt.Right does it. When I say it takes it to the next level, what I mean is it shows me things I know I should be doing (or in this case I’m fixing code that I got from someplace else. As it turns out, the place I got it from was Microsoft’s samples for building Windows Store 8 apps. If you want to find the original code, take a look at the WindowsBlogReader example to find the “before” code.
Examples
I’m just going to show two examples below of what CodeIt.Right suggests. I’m going to show them as a before with Suggestion by CodeIt.Right, and after which is what CodeIt.Right did automatically if I accepted the suggestion.
Example 1
And, code it right gives a little background on why it is suggesting this (you can customize your own rules, but this is the default)
I chose “Change type of the exception..” which gives me:
And now, I have:
Example 2
And finally, this one is pretty self explanatory:
Conclusion
CodeIt.Right is a keeper!