News for hackers. Stuff that matters.
Re:There’s No Such Thing as Clean Code by barrkel on Friday January 28, 2022 @06:56AM (#30113546)
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.

Re:There’s No Such Thing as Clean Code by yakubin on Friday January 28, 2022 @07:51AM (#30113932)
I agree. What I'm saying is that private is a poor default.
Re:There’s No Such Thing as Clean Code by thfuran on Friday January 28, 2022 @08:33AM (#30114333)
Why? I think it's pretty reasonable to only expand APIs deliberately.
Re:There’s No Such Thing as Clean Code by yakubin on Friday January 28, 2022 @08:58AM (#30114609)
Because 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.