Legacy code is code that was not developed according to current standards of software development, is no longer
maintained, and often is not or insufficiently documented. However, external, proprietary closed-source libraries often
meet these criteria too. Often, this code is still operated and needs to be adapted from time to time, e.g., to comply
with regulatory requirements.
Legacy code often comes in the form of CLOBs. An undefined mass of lines of code, of which no one knows anymore what it
does. The first step is to break down the system into its logical components. However, peripheral systems are often
integrated via 3rd party libraries, and access to them occurs from the presentation layer through all other logical
layers to the peripheral system in a single method. Before such a method can be refactored, the dependency on the
peripheral system must be decoupled to write a test for the existing method.
A simple tool from the Java toolset for decoupling the peripheral system is the ServiceLoader. The ServiceLoader is a
simple dependency injection mechanism and part of the Standard Edition, i.e., available in every Java Runtime
Environment since version 6.
To use the ServiceLoader, you need three elements:
Continue reading