4 ms·
Private - or visibility scoping generally - is absolutely essential when you program in an environment with multiple teams. In its absence other people take de
by barrkel 5y ago
Private - or visibility scoping generally - is absolutely essential when you program in an environment with multiple teams.
In its absence other people take dependencies on internal details which makes code much harder to refactor later. Lack of scoping on visibility increases the surface area of your APIs and increases the likelihood of bugs. Lack of scoping of visibility on state means losing almost all control over preservation of invariants.
- yakubin 5y agoI agree. What I'm saying is that private is a poor default.
- thfuran 5y agoWhy? I think it's pretty reasonable to only expand APIs deliberately.
- yakubin 5y agoBecause most things in healthy programs aren't APIs, but just plain data: records, sum types and composites thereof (arrays, stacks, queues, whatever). Fred Brooks: > Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious. In that situation, having to sprinkle "public"/"pub" all over them is very noisy and unproductive. It's the worst with Rust's enums, which require you to declare the visibility of variants and enclosed types of variants separately, so you see a couple "pub"-s per line of an enum definition. That may be an argument for separate keywords for plain data, and for "APIs", although I'm not sure how I feel about it. Underneath it's just coupling of data with functions. Some languages have separate keywords for those, some don't.