posted on Monday, May 23, 2005 6:40 PM
by
johnwood
The Usefulness Of #warning In C#
There are often times when I'm writing code that I knowingly take a shortcut, sometimes because of a deadline, sometimes because I'm impatient and just want it to work, and sometimes because of pure laziness. It might not even be a shortcut, just that I'm aware that this one particular bit of code will be critical to the performance of the application and might need reviewing to make sure it's written to run as optimal as possible.
The guilt of writing such code is often unbearable so I decorate the area of code with something that reminds me to go back and visit it later. For this I use the #warning, which lets you generate a level 1 warning in your source code. The warning will appear every time you compile so it's quite difficult to ignore. I know that some use // TO DO, but personally I don't find this very useful because the todo item appears in your task list and is lost / filtered out when you build.
It's also something that's easy to search on, for those days when you're looking for some code to optimize - you just do a find-in-files for #warning and that's your task list for the day.