From b8ad4d0d2fd71c3a0225ac1d2638616ab844c9aa Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 10 Mar 2024 23:27:18 +0000 Subject: [PATCH] Add daily email for 2024-03-08 Conventions over readability? --- source/_daily_emails/2024-03-08.md | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 source/_daily_emails/2024-03-08.md diff --git a/source/_daily_emails/2024-03-08.md b/source/_daily_emails/2024-03-08.md new file mode 100644 index 00000000..52783249 --- /dev/null +++ b/source/_daily_emails/2024-03-08.md @@ -0,0 +1,36 @@ +--- +title: Conventions over readability? +date: 2024-03-08 +permalink: archive/2024/03/08/conventions-over-readability +tags: + - software-development + - clean-code + # - php + # - podcast +cta: ~ +snippet: | + Which is more important? To write readable code or following existing conventions? +--- + +I previously wrote about why you shouldn't use variable names like `$x` and `$y` in your code and why you should use more descriptive names. + +But what if there is an existing convention? + +For example, I use Lua to configure Neovim and noticed that it's common to use shortened variable names, such as `buffer` instead of `buffer_number` or `bufferNumber`. + +It's also common to use the variable `M` to declare a module. For example: + +```language-lua +local M = {} +M.find_files = function() + // ... +end + +return M +``` + +Whilst `Module` would be a more descriptive name, would deviating from the convention be more confusing for anyone reading the code? + +Do the benefits of following a convention outweigh the benefits of using more descriptive variable and function names? + +Which would be easier for newcomers to your project or team to understand and allow them to be productive sooner?