4 ms·
Function comments should explain what it does, and comments inside functions should explain the how. // Receives n >= 0 and returns the n'th fibonacci number
by marcos100 5y ago
Function comments should explain what it does, and comments inside functions should explain the how.
// Receives n >= 0 and returns the n'th fibonacci number
int fib(int n) {
// We use the memoized version of the algorithm.
}
- gergi 5y agoThe code should explain what it does. In-line comments should provide explanation for any non-intuitive code that can’t be refactored to an intuitive state. The function comments should be about the intent of the code.