Friday, December 21, 2012

There's nothing magical about magic numbers

This magic number's intent is not clear:

<option value="3">

It's hard to know where in the program uses the value 3 and what is its meaning.

If we do it like the following, it's self-describing and we can find(Find Usages (Alt+F7)) what part of the program uses the value, things are a lot better:

<option value="@((int)ReportingModule.Products)" >

That's more magical!

Happy Coding! ツ

No comments:

Post a Comment