DEV Community

Discussion on: On the journey to writing better comments

Collapse
 
phlash profile image
Phil Ashby

This is also known as the pseudocode approach, which has good and bad points, as @danrot90 brought up here: dev.to/danrot90/code-comments-are-... =)

There is a similar but possibly more helpful approach (that I am unable to find my original reference for sadly - too long ago!) whereby you assume dependent objects have the methods you need to write a complete piece of logic, so you concentrate on the one thing, then go back and fill out the dependencies later (the compiler will nicely tell you what's missing!) - avoiding getting lost in the wormhole of implementation detail. I use this a lot :)

Collapse
 
christiangroeber profile image
Christian Gröber

Yeah I guess that's a very valid argument. But I don't think my approach really repeats what the code does, it summarizes what a code Block is supposed to do, so if we look at the example from my post and I decide I want to change how the name of the file is determined. Now I can tell, just by looking at the comments, that that will have to be in the first code block.