A fantastic post about the dangers of trying to standardise your codebase too early. I’ve been using this as a guide for the greenfield work I’m doing today https://t.co/zRgKf1vuKo
Here’s some advice from a former junior to current senior programmers: if someone is explaining their thoughts on an issue which you have already formed a conclusion about, let them explain their process, don’t relish it as an opportunity to tell someone why they are wrong
Another good argument for writing single-line comments is that it helps you with the Single Responsibility Principle. If you can’t describe the class in a line, or if that line includes the word “and”, it’s probably a sign the class is doing too much
I’m growing to love the rubocop rule requiring all classes to have a comment explaining what they do. Seems unnecessary when you’re forced to do it but it really helps clarify what exactly classes like “MediatorService” or “PlatformFinder” are actually DOING
@mperham I’ve always found that whenever I get mad about a given rule making no sense I look it up on GitHub and find a clear argument in favour, complete with links to the style guide and its rationale. Often it’s enough to change my mind, and if not there’s rubocop:disable.
Lately I’ve discovered that when you write smaller classes, lots of other things just fall into place. Unit tests get less sprawling because they are asserting that less stuff happens. Methods can be more explicit because saving lines isn’t a priority to keep things readable.
Just refactored a small piece of code using the principle that if you have to explain it with a comment then it could be made clearer. I thought the implementation on the left looked good and is pretty "clever" but the implementation on the right makes it clearer what is going on