One of the greatest things about our field is that there are so many people turning their ideas into useful code and making it available to the world in the form of open source software. But the effort of writing that code could be for naught if users don’t use it and developers don’t develop it. Thankfully, there are guidelines that when followed, minimize the chances of ending up in this predicament. These guidelines are known as the Three Prime Directives for Open Source Development.
Today, I’m going to look at Spring-Loaded, an open source program that enables live reloading of class files in a running JVM, and determine how well it meets the three prime directives.
Prime Directive #1
The first prime directive is that the system must successfully accomplish a useful task and I think Spring Loaded does this.
We all know that writing and debugging code can be difficult and any tool that can aid us in this process is a valuable asset. In a previous post, I talked a little bit about one such tool called LiveReload and how its changed the way I develop websites. By detecting and immediately displaying changes made to html and css files, LiveReload makes my modifications visible in near realtime. This allows me to quickly evaluate each change and decide on the subsequent action without the interruption of having to reload the browser manually. LiveReload is a valuable tool that has increased my efficiency and productivity.
Spring Loaded is like LiveReload except that it works in the JVM instead of your browser. Spring Loaded monitors your java class files and incorporates any changes you’ve made into the running JVM. In the same way LiveReload can increase a developers efficiency while creating websites, Spring Loaded can increase efficiency when developing java applications.
By delivering on its promise of dynamically loading modified java class files without the need to restart the JVM, Spring Loaded meets this directive.
Prime Directive #2
The second prime directive is that an external user must be able to successfully install and use the system.
There is no installation process as Spring Loaded is distributed as a java jar file. Enabling it is straightforward and accomplished by executing the following command in the terminal:
java -javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify YourJavaClass
The developers don’t provide a lot of documentation on the installation and usage of the tool but I suspect that this is because, from the developers perspective, both of these processes are easily accomplished.
I, however, discovered two caveats that I think would be useful for users to know prior to using Spring Loaded. The first is that the code needs to be manually compiled before Spring Loaded will recognize and reload the class files into the running JVM. The second is that it seems that any class in the java file containing the main method cannot be dynamically reloaded. All additional classes must be implemented in their own .java file.
In my tests, I created two classes: SpringLoadedTest and Printer. The Printer class contained three methods, printNum() which printed digits 1-5, printChar() which printed characters a-e, and print() which was called by the SpringLoadedTest class and called either printNum() or printChar(). During execution, I alternated between calling printNum() and printChar() in the print() method and this change was reflected in the running JVM.
Changes to java class files are live reloaded in the running JVM.
Once these two caveats are understood, using Spring Loaded is simple but a beginner may abandon the system before ever reaching this point. Therefore, due to lack of sufficient user documentation, I believe Spring Loaded fails to meet this directive.
Prime Directive #3
The third and final prime directive is that an external developer must be able to understand and enhance the system.
Although the developers make their code available on Github and encourage people to fork the repo and submit code for consideration to commit, there is no resource to guide new developers through the architecture of the software. There’s no website, no discussion group, no youtube channel, etc. Developers interested in contributing must download the code and make sense of it on their own. For this reason, Spring Loaded fails to meet the third prime directive.
Overall, although Spring Loaded failed to meet 2 of the 3 prime directives, I think it is a useful tool and will continue to use it when developing java applications. Perhaps, with enough time and use, I could be the developer that commits the code that brings this open source software to achieve the two failed directives.