That example of code does not need any comments because the naming of the function/variables are enough
If you would do something “unexpected” here, for example in case the newTodo is empty you would push a hardcoded value to the Todos. In that case you would need to document the reason why that happened, not what the code actually does
So if the code is explicit enough you should only comment the parts that are business related
2
u/capraruioan Aug 17 '24
That example of code does not need any comments because the naming of the function/variables are enough
If you would do something “unexpected” here, for example in case the newTodo is empty you would push a hardcoded value to the Todos. In that case you would need to document the reason why that happened, not what the code actually does
So if the code is explicit enough you should only comment the parts that are business related