O'Reilly logo

Java 9 Modularity by Sander Mak, Paul Bakker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. A Modular Future

We’re nearing the end of our journey through the Java module system—starting from the modular JDK, all the way through creating your own modules and migrating existing code to modules. On the one hand, there’s a lot of new functionality around modules to take in. On the other hand, Java modules simply encourage tried-and-true best practices around modular development.

Using modules for new code is recommended except for the smallest of applications. Applying strong encapsulation and managing explicit dependencies from the start lays a solid foundation for maintainable systems. It also unlocks new capabilities such as creating a custom runtime image with jlink.

Entering the modular future of Java requires adherence to the principles of modularity. When your existing applications have a modular design, the transition will be smooth. Many people already use multimodule Maven or Gradle builds for their applications. Often these existing module boundaries map naturally to Java modules. In some cases, the ServiceLoader mechanism offered by the JDK is a good alternative to using a full-blown dependency injection framework.

However, when your applications are anything but modular, the transition will be challenging.

Behind The Lines by Oliver Widder link:http://geek-and-poke.com/geekandpoke/2010/9/23/behind-the-lines.html, CC-BY link:https://creativecommons.org/licenses/by/3.0/deed.en_US

You saw in earlier chapters that it is certainly possible to migrate existing applications to modules. When their design is lacking in modularity, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required