3 ms·
If you have a block of code and feel that the block warrants an explanation, that block of code should receive a name instead. A block of code with a name. Beho
by cultureswitch 3y ago
If you have a block of code and feel that the block warrants an explanation, that block of code should receive a name instead. A block of code with a name. Behold: a function. Abstraction! Scary!
I do think things like types and functions should be documented, and on rare occasions there are tricks which can only reasonably be explained using code comments, but those are extremely rare.
- elnatro 3y agoYes you’re right, but sometimes in interpreted languages it’s difficult to understand what the function does. Python resolves this problem via type-hinting, Ruby relies on comments (although there are some approaches like sorbet).