Hacker News new | ask | show | jobs
by chapliboy 1831 days ago
I use comments to break up a large block of code into smaller chunks to explain what is happening / where we are in the process.

I used to be a firm believer in self documenting code, but that approach often led to a large number of functions that only get called once. So lately, I have been just putting a comment line where I otherwise would have refactored the code into a function, and I feel that it has made my code a lot easier to read, and understand.

2 comments

Same here. The majority of my code is usually readable but still add comments on bigger chunks of code to split that code into logical sections, it's particularly useful when using a text editor with code highlight
How has your testing been impacted? I usually write several functions to isolate code for testing.