Posts

Showing posts from December, 2010

Debugging TIP: Using class property to log intermediate values a variable takes

Recently I was involved in understanding how one program was running. There was so many things going on in the code just couldn’t understand the flow as it was too lengthy process to complete one full cycle of the execution while debugging. And after a few minutes and pressing F5 hundreds of times got fed up and decided to make an easy way doing this.
All I wanted was to know what all intermediate values a variable takes before the execution completes. In this example I want to keep track of the values that are assigned to my variable location
intlocation = 0;
To do this, a simple ways is to promote the local variable to class property & use the setter accessor of this property to do the task we want to do when the property value gets changed.
Make it to following change to the code and execute the program. You will have a Test.log file created in your bin directory and will have the list of values that are assigned to locationProperty while execution.
int_location = 0;
publicintlocat…