Until recently package private was not very popular. You could also test classes that are internal to the package, which gives you some flexibility when deciding what constitutes the unit of code you want to test. Thanks to this you can divide your module into smaller structures, each of which exposes an external interface to communicate with. This prevents them from exposing internal implementation. Developers need to consciously decide which classes constitute a package’s external APIs. The decision to make package private the default modifier in Java was a good one. The same goes for fields and methods (which might not be as good ), but in this post we will focus on access modifiers as they refer to classes/top level constructs. This means that all classes created without additional access modifiers are visible only to the classes in the same package. The default access modifier in Java is package private. When it comes to visibility, Java designers made a wise decision when designing the language. However, they are often surprised by a missing feature: package private. New developers coming to Kotlin from Java enjoy a variety of new language features, syntactic niceties and overall improvements.
0 Comments
Leave a Reply. |