Effective Kotlin: Item 15 — Minimize the accessibility of classes and members

If you are writing APIs item 15 of Effective Java by Joshua Bloch is hugely important. The principle is simple, “make each class or member as inaccessible as possible” to hide the internals, and dependencies, of your classes.

The developers of Kotlin took the opportunity to improve on Java, and the visibility modifiers were no exception. As with Java, there are four modifiers, but with subtle differences aiding API developers:

  • private — top-level definitions visible in their…