Refactoring For Grokking

I HaveThisPattern a lot. When going over some code I'l use RenameVariable?, RenameField? or RenameMethod a lot (thanks EclipseIde) and to a lesser extent AddMethodComment?.

I like it as it makes it very clear which code I have seen/read before and it makes my misunderstandings very clear (for example when a variable boolean back that seems to echo the value of a Search Backwards checkbox , that I just renamed to "isSearchingBackwards" is actually used so that true means search forwards). Then another refactoring occurs...

AddMethodComment? helps me a lot keeping me from needing to hold information in my head as I find it. Also it makes the CodeSmell that is there so much easier to see and fix afterwards.

This occurs a lot to me - though I shy away from doing other refactorings for grokking, as I fear breaking things (no tests around usually...)

These are the only refactorings I use for grokking I'd like to know if some of you use more or different ones. Perhaps I'm missing something?

I ExtractMethods. Then extract methods some more. This really works on legacy procedural stuff. It may be less effective on code where LotsOfShortMethods are already the norm.


See also TipsForReadingCode


EditText of this page (last edited October 13, 2012) or FindPage with title or text search