Should you /* comment */ on kata solutions? #2459
Replies: 3 comments
-
Ofc, it is. It would be very helpful for learners especially on hard-level katas (blues and purples) |
Beta Was this translation helpful? Give feedback.
-
Yes, it's good practice. Someone else might not immediately see through the code to understand its intent, and that someone else might be you six months from now. ( I myself have certainly been on both ends of this phenomenon. ) So why don't we do it? Laziness, and a chronic tendency to overestimate how self-explanatory our code is. Often, our code fits the way we reason about a problem, so the code will make more sense to ourself than to someone who might reason differently about the same problem, but even then reasoning backwards from code to problem can be harder than reasoning from problem to code. Including a high-level description of the approach taken to solve a particular problem is A Good Thing. If you are going to comment |
Beta Was this translation helpful? Give feedback.
-
No one likes comments in production, because it can become outdated sometime. But comments are good practice for complex custom solutions in trainings. You can return later to them and easyly remember what did you write. |
Beta Was this translation helpful? Give feedback.
-
I like to go back to my kata solutions once in awhile to check something I did in the past, and that I might need in order to solve something today. Is it good practice to comment out your solutions explaining the logic in your code or is that to be avoided? I noticed no one ever does this and was wondering why?
Beta Was this translation helpful? Give feedback.
All reactions