3 ms·
Steve McConnell advocates a similar thing in Code Complete 2, which he calls Pseudocode Programming Process, PPP. The idea is that when first creating a method
by gustavo_duarte 17y ago
Steve McConnell advocates a similar thing in Code Complete 2, which he calls Pseudocode Programming Process, PPP.
The idea is that when first creating a method or function, you write out in comments what you're going to do in a 'why' level (eg, 'keep track of resources') rather than a 'how' level (eg, 'increase cntFooBar by 1').
You then start 'filling out' the code to do what you 'designed' via the comments. Hopefully you end up with a better designed routine, and you get free comments to boot as they now explain what the code is doing.
When I first read Code Complete as an impressionable teenager I tried it out and liked it, but I have since had a change of heart on this issue and other Code Complete wisdom. I rarely comment inside methods anymore.
- derefr 17y ago> You then start 'filling out' the code to do what you 'designed' via the comments. Another approach is to just drop the comment markers entirely, massage the pseudocode until it's valid syntax, and then write a DSL that does the right thing upon its execution. That way, all you ever really have is comments.