4 ms·
Why not actually write an example (like a short blog post, containing some code snippets), in the comment, using the native language, instead of commenting the
by random42 15y ago
Why not actually write an example (like a short blog post, containing some code snippets), in the comment, using the native language, instead of commenting the live code?
Dont you think it would improve the readability of the code? Sure it takes slightly more time, (may be 10 extra mins, for a small example), but I can assure you, a newbie, who is new to the codebase/language, would certainly appreciate such an example. (I know, I would have.)
- chrislomax 15y agoI do it because its inline. If someone is looking over the code and right above the recursion see's an example of what I am doing in my eyes makes it more readable. Don't get me wrong, it's not something I do every day, I may have done it 3 or 4 times in my life but I have done it. I mainly do it for debugging purposes. If you are stepping through and you can see a string example of the output you can instantly compare it to your built string of JSON. I am probably just being pedantic but I can see a use for commenting certain code. If i blog posted it and changed it then I would need to make an active effort to update the blog. It would be like maintaining documentation. I can just update the comment above and be on my way. I think everyone has their own methods and I'm not saying yours is wrong, I am just saying I do see a need to put code in comments sometimes. There are only two devs here though and we know what we are doing, if a noob came in then to be honest they wouldn't be touching my code until they understand it anyway
- random42 15y ago> I am just saying I do see a need to put code in comments sometimes. Yup, There are rules, and then, there are rules. The important thing is to realize what practice makes sense, for the given condition... and why.