Saturday, December 21, 2013

More on Dead Code

There is one more type of dead code which is sometimes automatically detected by today’s IDEs those are like condition based. A code fragment runs only when a certain condition is met. This gets created based on the developer's initial thoughts in the first-time. Latter the code gets modified by the same developer after few weeks/months or by some other developers.

This happens because of the same reason as I mentioned in earlier post that they fear to remove and refactor the code base. The moment it starts working they just close it and say it’s done!

Example:

var customerIsPreferred = true;
if (customerIsPreferred)
{
     DoSomething();
}
else
{
     DoSomethingElse();
}


No comments:

Post a Comment