Archive for December 29, 2007

Refactoring – An analysis of intent (Part II – Understanding)

Decorative PictureSummary: We can roughly taxonomize the type of understanding needed from source code by considering:

  • Whether the reader is trying to understand what code does or how it does it.
  • Whether the reader wants a vague or exact understanding.
  • What fraction of the code is the reader trying to understand. Are they just trying to understand a local area or are the trying to understand the program globally as a whole?

For each type of understanding, some types of refactoring may make understanding easier, whilst others may make it harder. This is particularly relevant for vague understanding and local understanding.

Regardless of what the reader is trying to understand, some things just make reading code easier. Writing code that is the same as – or analogous to – code that others have already written makes understanding a lot easier. Making code consistent allows the reader to remember a limited set of rules rather than actual details. Doing what people expect means they won’t be suprised and confused. With this is mind, we see that using patterns and idioms makes code a lot easier to read – provided that the reader knows the idioms and patterns. Some refactoring may be good at doing this – other refactoring might be bad…


(more…)

December 29, 2007 at 4:21 pm 1 comment


December 2007
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930
31