My Account Log in

2 options

Modular programming in Java 9 : write reusable, maintainable code with the Java Platform Module system / Koushik Kothagal.

Ebook Central College Complete Available online

View online

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Kothagal, Koushik, author.
Language:
English
Subjects (All):
JavaScript (Computer program language).
Physical Description:
1 online resource (287 pages)
Edition:
1st edition
Other Title:
Write reusable, maintainable code with the Java Platform Module System
Place of Publication:
Birmingham, [England] ; Mumbai, [India] : Packt Publishing, 2017.
System Details:
text file
Summary:
Kick-start your modular programming journey and gear up for the future of Java development About This Book Master design patterns and best practices to build truly modular applications in Java 9 Upgrade your old Java code to Java 9 with ease Build and run a smooth functioning multi-module application. Who This Book Is For This book is written for Java developers who are interested in learning and understanding the techniques and best practices to build modular applications in Java. The book assumes some previous programming experience in Java 8 or earlier, familiarity with the basic Java types such as classes and interfaces, as well as experience in compiling and executing Java programs. What You Will Learn Get introduced to the concept of modules and modular programming by working on a fully modular Java application Build and configure your own Java 9 modules Work with multiple modules and establish inter-module dependencies Understand and use the principles of encapsulation, readability, and accessibility Use jlink to generate fully loaded custom runtime images like a pro Discover the best practices to help you write awesome modules that are a joy to use and maintain Upgrade your old Java code to use the new Java 9 module system In Detail The Java 9 module system is an important addition to the language that affects the way we design, write, and organize code and libraries in Java. It provides a new way to achieve maintainable code by the encapsulation of Java types, as well as a way to write better libraries that have clear interfaces. Effectively using the module system requires an understanding of how modules work and what the best practices of creating modules are. This book will give you step-by-step instructions to create new modules as well as migrate code from earlier versions of Java to the Java 9 module system. You'll be working on a fully modular sample application and add features to it as you learn about Java modules. You'll learn how to create module definitions, setup inter-module dependencies, and use the built-in modules from the modular JDK. You will also learn about module resolution and how to use jlink to generate custom runtime images. We will end our journey by taking a look at the road ahead. You will learn some powerful best practices that will help you as you start building modular applications. You will also learn how to upgrade an existing Java 8 codebase to Java 9, handle issues with libraries, and how to test Ja...
Contents:
Cover
Copyright
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Table of Contents
Preface
Chapter 1: Introducing Java 9 Modularity
Modularity in Java
Rethinking Java development with packages
The unfortunate tale of a library developer
The impossible task of a deployment engineer
The classpath problem
Java - the 20-year-old code base
Legacy classes
Internal APIs
Java Platform Module System
Project Jigsaw
Summary
Chapter 2: Creating Your First Java Module
Setting up the JDK
Switching between JDKs
Setting up the NetBeans IDE
Java 9 modules
Traditional Java code structure
What is a module?
Creating a module
Creating your first Java module
Compiling your module
Executing your module
Creating a module using NetBeans
The address book viewer application
Handling possible errors
Chapter 3: Handling Inter-Module Dependencies
Creating the second module
Compiling two modules
Configuring module dependency
Module versioning
Rethinking package structure
Understanding module path arguments
Revisiting classpath
Revisiting the classpath problems
Chapter 4: Introducing the Modular JDK
Examining the legacy JDK
The JRE structure
Understanding rt.jar
The problem with this model
The attempted solution - Compact profiles
The state of API encapsulation
Understanding internal APIs
The attempted solution - Deprecation, warnings, and documentation
Enter Project Jigsaw
Platform modularity
The impact of platform modularity
Module graph
The java.base module
Browsing modules
Module types
Examining platform file structure
Observable modules
Revisiting the two problems
Solving the monolithic runtime.
Solving the API encapsulation problem
Chapter 5: Using Platform APIs
Adding logging ability
Using an alternative compiler command
Reading contacts from an XML file
Removing the hard-coded contact list
Creating the module
Coding the XmlUtil class
Coding the ContactLoader class
Shared classes
Dependency leakage
Consuming the new module
Adding UI with Java FX
Chapter 6: Module Resolution, Readability, and Accessibility
Readability
Accessibility
Interface and implementation accessibility
Split packages
Tweaking modularity
Implied readability
Aggregator modules
Java platform aggregator modules
Qualified exports
Applying the concepts to address book viewer
Creating a custom aggregator module
Optimizing module imports
Optimizing module exports
Chapter 7: Introducing Services
The problem of coupling
Understanding services
The service registry
Creating and using services
Implementing sorting services
Drawing the module graph
Advanced services
Supporting singleton and factory providers
Implementing service priorities
Service interface provider lookup
Selective service instantiation
Services and the module system goals
Chapter 8: Understanding Linking and Using jlink
Module resolution process
Module resolution steps
Examining module resolution in action
Revisiting the state of the JDK
Linking using jlink
The jlink command
Link phase optimizations and jlink plugins
Building a modular JAR file
Chapter 9: Module Design Patterns and Strategies
Designing modules
Scoping
Team structure
Reusability
Modularizing by concerns
Modularizing by layers
Modularizing by change patterns
Designing API.
Java modules coding patterns and strategies
Pattern 1 - Public interface, private implementation, and factory class
Example
Pattern 2 - Services for multiple dynamic implementations
Pattern 3 - Optional dependencies
Pattern 4 - Optional dependencies using services
Pattern 6 - Bundle model classes as separate sharable modules
Pattern 7 - Open modules for reflection
Pattern 8 - Use tooling for version control
Pattern 9 - Design for changes
Pattern 10 - Protect against dependency leakage
Pattern 11 - Aggregator and facade modules
Chapter 10: Preparing Your Code for Java 9
Beginning Java 9 migration
Introducing the sample Java 8 application
Using the Java 9 compiler and runtime
The unnamed module
Handling non-standard access
The jdeps tool
Overriding module behavior
Understanding the impact
Recommended strategy
Chapter 11: Migrating Your Code to Java 9
Understanding the migration goal
Beginning the migration
Automatic modules
Automatic module naming
Automatic module definition
Migrating with automatic modules
Using jdeps to outline module relationships
Refactoring into smaller modules
Handling larger codebases
Migrating libraries
Reserving library names
Using jdeps to create module descriptors
Building libraries for multiple Java versions
Chapter 12: Using Build Tools and Testing Java Modules
Integrating with Apache Maven
A Maven refresher
Using Maven with Java 9 modules
Working on a multi-module Java 9 Maven project
Building the multi-module project
Executing the multi-module project
Understanding the exec plugin's module path
Unit testing modules with Java 9
Testing a Java 9 module
Integrating with JUnit
Wrapping up
Summary.
Index.
Notes:
Includes index.
Description based on online resource; title from PDF title page (ebrary, viewed September 25, 2017).
OCLC:
1004746798

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account