by junon · 4y ago · 0 comments
I don't agree with it, I use mixed visibility members in most languages I use. The closest "rule" to this that is more just a side effect of my experience is that most data members are private by default unless there is a public read/write contract, or if they are data members that are marked const in a language that supports such things.
Beyond that, employing any sort of rule generally means you're writing more code than necessary, or less code than is helpful, and inflicting that pain on consumers or colleagues.
Dogma is rarely the way to go, in my opinion. Being good at being pragmatic is certainly a skill, and it's much more powerful than a subjective rulebook.
On one axis is how mechanical the rule is. One end is rules like the one in this article where even a simple automated syntactic analysis could enforce the rule. The other end is rules around high level principles that require taste and judgement to apply like the principle of least astonishment (What is "astonishment"? Whose? How is it compared?), single responsibility (What is a "responsibility"? What does it mean to uphold it?).
But there is a second axis too which is how literally the guideline is meant to be applied. People often assume that the more mechanical a rule is, the more mechanical you should be in applying it, but that's not the case. It's reasonable to have simple mechanical rules that have plenty of exceptions and require some judgement to know when to ignore them. Likewise, there are vague high level principles that should almost never be violated.
When someone assumes that a mechanical rule should be applied blindly, they call it "dogma", but a more charitable interpretation is that the author expects the reader to not follow the rule blindly and understand that there are reasonable exceptions.
Mechanical rules can be useful, but mechanical rule-followers less so.