4 ms·
I think a lot of this can be generalized as: - Don't force people to guess. Guessing takes time, and is an opportunity for a mistake. - Explicit information i
by partycoder 10y ago
I think a lot of this can be generalized as:
- Don't force people to guess. Guessing takes time, and is an opportunity for a mistake.
- Explicit information is better than implicit information. Abbreviations, incomplete identifiers are a form of implicit information.
- Lying exists in programming. Identifiers that do not match their purpose can mislead programmers and introduce bugs. e.g: Including side-effects in a function is called "get", "read" or "retrieve".
- Coupling brings more information into a scope, making it more complex and decreasing readability.
- slau 10y agoThis may not be a popular opinion, but for me read and retrieve are indicative of a side-effect. I consistently use retrieve to indicate fetching things from database, or remote locations (REST, RPC, whatever). Similarly, read, in the case of a parser or whatnot, indicates that the buffer will be advanced. Maybe I'm just too biased because I try to have const-correct/mutable-correct code?
- grzm 10y agoSounds like you're building up a set of conventions which can be very useful when you're consistent with them and communicate them to others reading your code.
- clusmore 10y agoAgreed, these words have similar connotations for me as well. I have also seen deliberate usage of set vs update to indicate changes to objects in memory only vs persistence to databases, etc.
- dllthomas 10y agoAnd of course, with sufficiently aggressive optimization, there may not actually even be a change to an object in memory (or the object in memory to change) in some cases. Not so with the database.
- partycoder 10y agoIf it's a partial read that requires to track state, then yes. If it's a somehow self-contained read operation that returns a result, while it has side effects (I/O), it may not necessarily have to mutate variables in your program (e.g: load a small file into string variable, make a HTTP response and return the body, etc).