Read more

Clean code: Avoiding short versions in command options

Emanuel
April 19, 2021Software engineer at makandra GmbH

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.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

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
Posted by Emanuel to makandra dev (2021-04-19 08:43)