Ifdef Comments

IfdefComments are comments embedded in the argument to an #ifdef directive in CeeLanguage and CeePlusPlus. Generally, the argument to this sort of #ifdef should never be defined (or else all heck will break loose). (It is probably possible to identify a block of code with an #ifdef that is always defined; but this use is far less common).

Examples:

 #ifdef REMOVE

Code inside the #ifdef/#endif has been intentially removed; but programmer wishes to keep it visible for a while. A good VersionControlSystem makes this use of #ifdef unnecessary; but sometimes this is more convenient than plowing through the Clearcase (or whatever) logs to find what was deleted.

 #ifdef REMOVE_MM_DD_YYYY (or REMOVE_DD_MM_YYYY if you prefer)

Better version of the above; identifies when the code was ifdef'd out. When refactoring, such blocks that are old enough can be physcially removed altogether.

 #ifdef KEEP (or KEEP_date)

Code that is removed; but should remain visible in the source (for whatever reason).

 #ifdef LATER_MAYBE or #ifdef NEEDED_FOR_foo

Code that might be needed to implement a future requirement. Often times signifies a violation of YouArentGonnaNeedIt (though violations of YAGNI that are commented out are better than those which are compiled in); may also reflect a partially implemented feature that was deleted from the requirements.

Sometimes spelled

  #if 0

CeeIdioms


EditText of this page (last edited September 26, 2003) or FindPage with title or text search