Working with Legacy code #2 : Understand it.

In my last post I suggested drawing up a plan, the plan might be based on what you and the team already know of the code and your experiences so far in coding, fixing and refactoring attempts on the code base. Your plan might need further detail when you start to get into the finer detail of the codebase and into areas you and team may have never have been into before.

There are a great deal of ways you can do this, simple debugging and breakpoint for example but the detail learned can be lost if only ever used by it’s self. Another approach is logging intercepts to log method calls as and when they occur. Using something like log4net can allow you to log to what ever medium you want with relative ease, if you don’t want to leave logging calls around then a clean solution is combine with PostSharp. A third approach is a static analysis tool such as NDepend which allows you to really drill into the codebase. A fouth approach is to use code profiling tools like ANTS or dotTrace.

Combining the above can be a very powerful way of getting what the code is doing, for example tracing the code to understand the paths through the code that is taken and using static analysis tools to explore those classes\methods dependencies further.

The final step is documenting what you find, the more you find the more may go onto your plan. Your findings may change the order of your plan if you find objects are worse than you first thought.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s