Wednesday, August 26, 2009

Achtung Baby! (Warnings are your friend)

I'm busy with a release this week so the posts will be slim.

As a release nears the time available to get anything done decreases and the temptation to ignore "little things" increases. Compiler warnings tend to get ranked lower on the "need to fix" scale when deadlines loom large.

I experienced a cautionary tale in why compiler warnings are important, even when time is short, during a recent build. While developing a class I realized that it needed a few more properties. So I added the properties to the class, added parameters for the properties to the constructor and completely forgot to set the properties in the constructor.

C# dutifully warned me that "parameterX is not being used". Unfortunately this streamed by in the output window and was lost amidst the flurry of other warnings that have crept into the source code over the past few years. This resulted in several minutes wasted scratching my head over why the property was never changed from its default value even though it was clearly being passed a new value in the constructor.

Gotta take advantage of the freebies that life gives you. Compiler warnings are freebies - it's foolish to ignore them.

No comments :

Post a Comment