Marking Code For Later Attention
· Apr 2, 01:05 PMWhen engaged in the Big Refactor, it is often the case that you want to mark code for later attention. Perhaps one refactoring has broken some other code, and you’d rather not deal with it now. The immediate solution is to comment it out, and perhaps add a comment to remind you what needs to be fixed. And then you forget about it, and only remember in the course of figuring out why things don’t work later.
Here is a simple trick that enlists the compiler to help you remember. Add a module to your code, and to it a constant like
const ToBeResolved = false
Now instead of commenting out code, wrap it along with your notes into a pragma block.
#if ToBeResolved
this code needs to be reworked to use the new
Foo class interface
blah
blah
blah
#endif
Now, the compiler will ignore everything inside the block, allowing you to stay on task with the refactoring. Later, you can change the value of ToBeResolved to true, and the compiler will tell you about compile-time errors in the code whose reworking was deferred. You can check the code for a single class, or the entire project.
Comment
Commenting is closed for this article.
Matching a Quoted String With a Regular Expression Pretty-Printing XML: A 'Hello World' Example
Brilliant, Charles. Again.
Regards,
Tony Barry
— Tony Barry · May 27, 03:34 AM · #