Single quotes or double quotes
People sometimes wonder:
Should we use single quotes (
'
), or double quotes ("
) for strings?
The question that is much more rare is:
Can we settle for one character for marking our strings, consistent around our code base, and apply it right now?
The first question is difficult, requires (or seems to require) discussion around the entire project, and then execution (only if people agree that one is "better" than the other – because that's how that question is understood implicitly).
The second question can be decided in minutes, and by anyone within the project.
As long as the language you're using doesn't tell the difference between single– and double–quoted strings (eg. Python), you are free to choose either one.
If you ever find the other quote mark superior, switching the project to it will be a relatively simple "replace" operation around the code base, followed by a common-sense review.
That's the approach Black promotes:
Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting. You will save time and mental energy for more important matters.
– https://github.com/psf/black/blob/main/README.md
This is how Zach Alexander puts it:
As an author, don't make your reader work any harder than they already have to. It doesn't really matter what your style rules are - just pick some and be consistent. The best way to do so is by codifying them into linter rules and enforcing them at build time.
– Zach Alexander http://zpalexander.com/the-best-quotes-from-clean-code/
It's an example of asking a "big" question and getting stuck without a resolution, while a "smaller" question when asked and answered, would bring real improvement.
Uncle Bob mentions this fenomenon as "getting stuck", and proposes to focus on making tiny, incremental steps towards your goal instead [1].
- Write only enough of a unit test to fail.
- Write only enough production code to make the failing unit test pass.