4 ms·
Most counterarguments go something like "It's bad when everyone writes in their own style, that's why one style should be enforced." But this gets you right int
by hakunin 3y ago
Most counterarguments go something like "It's bad when everyone writes in their own style, that's why one style should be enforced." But this gets you right into the other extreme: code consistency is valued above comprehensibility. Now your code is harder to read because you format it mechanically, instead of using your own human consideration.
The right answer in my view is kind of what I think DHH is trying to get at: have enough rules to avoid straight up sloppiness and clear no-nos. Don't have any rules that might change based on human consideration.
- wiseowise 3y ago> Now your code is harder to read because you format it mechanically, instead of using your own human consideration. How so?
- hakunin 3y agoBecause humans can break a rule in favor of readability, symmetry, clarity. Linter can't.
- wiseowise 3y ago> Because humans can break a rule in favor of readability, symmetry, clarity. Care to show examples? I haven’t encountered a single one where that would the case.
- hakunin 3y agoWith Ruby, you have many different, expressive ways of saying the same thing. Examples that come to mind off the top of my head: deciding to vertically align keyword arguments sometimes. Wrapping code differently to meet a line length limit. Breaking the rule of "never making a variable one letter long" in tiny, clear code snippets to make everything read better. Choosing to use double vs single quotes (single quotes signal that the string has no interpolation). Putting a space at the start/end of array and hash literals in some cases. Using .call() or .() or [] to call a lambda. There are many other little things like that. Each one seems insignificant, but together they replace all human consideration. And since Ruby is very concise and efficient (small amount of code gets a lot done), expressing your "hows", "whats", and "whys"[1] in the most readable way should be where you spend some of your time. [1]: https://max.engineer/maintainable-code https://max.engineer/maintainable-code