Showing posts with label understanding. Show all posts
Showing posts with label understanding. Show all posts

Wednesday, October 6, 2010

Understand Source Code by Reading Code and Refactoring for Maintaining Large Projects

This list consists of one-liner tips to be used for easy lookup and reference.

Rewriting Code for Better Understanding (Coding Horror)

  • What I cannot create, I do not understand. [Richard Feynman]
  • "What I do not create, I do not understand."[Chris]
  • "It's easier to understand 600 tables than 100,000 lines of code." [PaulC on comp.databases.theory/2005]
  • Create a new project with blocks of code copied from old code. Refactor to reduce "old code smell"
  • Start refactoring by adding small tests to better understand code and act as regression tests.
  • Just scan through huge amounts of code till it starts making sense - "understand by constant exposure".
  • Create a text file to capture your understanding - briefly describe how the component works, realtions to other components, what it persists, its states, and source browsing/debugging tips you found useful.
  • Manually reformat a copy of the code - white space, and indented as per your personal style.
References:
  1. Working Effectively with Legacy Code
  2. Object Oriented Reengineering Patterns
  3. Refactoring: Improving the Design of Existing Code