Explicit actions imply intent, prefer implicit actions - Nils's website

submited by
Style Pass
2021-08-28 16:00:04

Software development (as well as many things in life) is all about making choices, one of them is deciding whether to do things in an implicit or explicit way.

Generally (based on my personal experience) the explicit option is the one that people recommend taking because it doesn’t require knowledge of the implicit behaviour and is more likely to be forward compatible.

For example, this could be when specifying arguments to a function, cli, etc. specifying the same values as the default values even though not specifying that argument at all would result in the same behaviour. Or in expressions, adding brackets for precedence even though it is not needed:

However, I believe that expressing things implicitly would be better in many of these cases because when expressing things explicitly an intent is implied: it is implied there is a reason why the thing in question is defined explicitly. “Why would someone go out of their way to do something?”.

I believe that this implied intent can lead to confusion. For example it can make someone believe the default is not what it is, or the operator precedence is not in the order it actually is and as a result, the implicit option is preferable in some if not most of these cases.

Leave a Comment