|
|
|
|
|
by rimantas
5050 days ago
|
|
> This is a fable bad programmers tell to themselves to
> justify their intellectual laziness.
No, actually commenting is easier solution for the lazy ones. Too bad they are to lazy to update the comments when something changes. > No real world code is simple and elegant enough that you don't
> need to think through the complex invariants of the code
Oh, please⦠|
|
> Oh, please...
What happens if delay is 0?Can user be NULL? What happens if it is NULL?
How large can 'data' be? Is there a limit? Will the send be chunked into multiple dispatches if 'data' is too large? Is that opaque to the caller? Does it matter to the caller?
If none of those questions are answered, the caller must delve into the sendDataWithTimeout() implementation to figure out the answers, and it is impossible to modify sendDataWithTimeout() without possibly breaking assumptions callers make based on what they've assumed from implementation of sendDataWithTimeout().
This applies equally well to blocks of code within a function that accept input and provide output. It helps to be able to reason about them as atomic units, without necessarily paying the code/maintenance cost of hoisting them into independent functions.