3 ms·
# NOTE(coderguy): Calling this method before calling # Init will result in a runtime error. I use comments to make people aware of invariants the code expe
by zaphar 10y ago
# NOTE(coderguy): Calling this method before calling
# Init will result in a runtime error.
I use comments to make people aware of invariants the code expects that aren't necessarily obvious from reading that code.
- tempodox 10y agoIf possible, document invariants as part of the code, not as a comment. Make it as hard as possible to misuse the thing. People not only don't read manuals, they also don't read comments. Which isn't to say you shouldn't comment your code.
- aidos 10y agoI wouldn't use a comment in that situation either - I don't think a comment hurts, but I'd rather the code failed in an obvious way if I tried to use it incorrectly. My comments are generally along the lines of "so you're here because you need to change something? here's what you need to know", rather than "this is how you use this thing".