Clean code: Avoiding short versions in command options

Posted . Visible to the public. Repeats.

This card is a general reminder to avoid the short version of a command option in shared code. It's much easier to understand a command and search for an option when it's written out.

You can still use the short version of the options in your own terminal or in code snippets that are more useful when they are very compact. For the latter case you often see a description of the command options one line below e.g. in posts on stackoverflow.

Example good (in code):

/usr/bin/gpg --output password.txt --decrypt password.txt.gpg

Example good (when you want a short version for copy & paste e.g in a wiki):

/usr/bin/gpg -o password.txt -d password.txt.gpg
Encrypts a file with GPG (-o output file, -d decrypt file)

Example bad:

/usr/bin/gpg -o password.txt -d password.txt.gpg
Last edit
Emanuel
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2021-04-19 06:43)