I’m totally aware of the benefits of encapsulation, but the way java does it seems so unnecessarily boilerplatey (C# is better, functional programming makes encapsulation even simpler, but that’s a different paradigm…)
I like how Rust approaches this via the module system and crates (you have pub for the public interface, pub(crate) for crate/lib wide access and no modifier for being only allowed to access in the current module and submodules of that module)
I’m totally aware of the benefits of encapsulation, but the way java does it seems so unnecessarily boilerplatey (C# is better, functional programming makes encapsulation even simpler, but that’s a different paradigm…)
I like how Rust approaches this via the module system and crates (you have
pub
for the public interface,pub(crate)
for crate/lib wide access and no modifier for being only allowed to access in the current module and submodules of that module)Not to aware of how c# works, or interested in defending java, especially ancient java versions, but what does it do better in that regard?
Only records for more or less pure data objects come to mind, but those are also in modern Java.
It has Properties (basically syntax sugar…)
And it’s so good that Kotlin adopted them too in their journey to fix Java.