Today I read java development tools/frameworks for a programming boost article by Theodora
Fragkouli. This inspired me to publish highlights of the training, I imparted
in last month to java developers, on "Tactics to improve
productivity in Java" topic.
The scope of this
training was stringent to relate Java technical viewpoints, and obviously
excluded thoughts of generic ways to boost productivity, i.e. do
yoga/meditation regularly, 15 minutes power nap at work, having cup of
tea/coffee... :-)
The objective of
this training was to make participants familiar with few notable tools, techniques and programming
considerations focused to boost java developers productivity. I focused
mainly on three areas.
(1)
Save time on java app compile, build and
redeploy process.
(2)
Efficient ways to analyze or review
existing/legacy java code.
(3) Less code means more productivity.
I demonstrated
following tips practically in the training, which java developers should adopt
for being more productive (* as applicable in the given project architecture
and development environment).
Before I start, I hope that you have already read "Preface" of my java power tools series.
Before I start, I hope that you have already read "Preface" of my java power tools series.
Tools and Techniques to
improve productivity
View Java code changes instantly using JVM HotSwap / class reloading tools
- Problem = By nature, if we do even single line of code change in java, we must need to wait for few seconds to minutes to test it until application is built and redeployed on server.
- Solution = JVM Hotswap or class reloading tools can help us to save time at certain extent, i.e. add and update java classes instantly without waiting on java app compile, build and redeploy process.
- JRebel (commercial) is superior than Hotswap Agent. You may read my another post for further information on JRebel.
- Hotswap Agent (free) is awesome compare to other free alternatives such as DCE VM, Spring-loaded, Fakereplace. You may read my another post to see Hotswap Agent in action.
- In general, I suggest such tool to use during development. Be cautious to use it in production, until you need to accomplish exceptional use case!
Reverse Engineering
technique and tools
- Useful to improve design documents of legacy systems or efficient way of exploring code from the generated diagrams (e.g. class and sequence).
- Static reverse engineering using ObjectAid (free for class diagram), i.e. generating diagrams from existing codebase.
- Runtime reverse engineering using Maintainj (commercial), i.e. firstly perform functional operation in running application and capture corresponding code flow traces, then explore the generated diagrams for the given executed use case and finally from diagrams navigate the exact code.
Static code analysis tools
& Dependency analysis technique
- Make manual or automated code review effectively using SonarQube (Developers' Seven Deadly Sins)
- Generate Dependency graphs using Codepro Analytix (free) or Dependency structure matrix (DSM) using SonarQube (free) from existing or legacy codebase to detect cyclic dependencies and empower the impact analysis for refactoring / reengineering / modernization, etc. Just google further, you would find many references to understand fundamental of these dependency analysis techniques using the mentioned tools.
- Interactive development using superior visual diagrams and CQLinq feature of JArchitect (commercial).
- You may read my another series of blog posts on static code analyzers.
Miscellaneous
- Enrich Eclipse IDE by adding extra Eclipse plugins - Code Recommenders + Snipmatch (code recommendation and a snippet completion engine), InstaSearch (fast text search in the workspace), MouseFeed (helps to form a habit of using keyboard shortcuts), JD-Eclipse (java decompiler), etc.
- Cronon (commercial) - a DVR for Java, offers to record your entire java program and replay on any machine.
- Search for Java API example - Excellent online interface to search for sample code snippets for the given java API (e.g. org.springframework.web.servlet.ModelAndView) and see how that API is used in various open source frameworks.
- Stackifier - A web page to make sense of verbose Java/Scala exception stack trace by translating into the simplified UI.
Less code means more
productivity
Less lines of code
means more productivity, and also less efforts to unit test and maintain the
code. Now the question is - what could be programming considerations for this?
Here we go...
Polyglot programming on the JVM
- Have you ever thought to mix-and-match multiple programming languages in a single application? Well, the phrase polyglot programming on the JVM was coined to describe projects that utilize one or more non-Java JVM (Java Virtual Machine) languages (e.g. Scala, Groovy, Clojure, Jython, Jruby, JavaScript...) alongside a core of Java code. All in all, it is better to use the right programming language to do the right job.
- Polyglot Programming with respect to Java platform --- Java SE 6: added specification for supporting multiple scripting languages in JSR-223, which encouraged acceptance of many popular open source languages on JVM runtime by just implementing scripting engine of given language. Also it allows java developers to call non-java scripting language (e.g. JavaScript, Groovy…) code from java code and vice versa. Java SE 7: added JSR-292 to enable developers of compilers for dynamically typed languages to generate bytecode that runs extremely fast in the JVM. Java SE 8: replaced default “Mozilla Rhino” JS scripting engine with new highly performant “Oracle Nashorn” engine.
- The Java specification doesn't talk about how the different languages should be organized in enterprise application architecture! So in general the polyglot programming environment can be categorized in three layers from architectural standpoint, so-called polyglot programming pyramid --- (1) Stable layer - The stable layer is what everything else is built on top of, and should preferably be a thin foundation. Statically typed language (Java, Scala) is suited for this layer, as performance and stability is of the utmost importance. All interfaces to external applications are also defined in this layer, as this will provide type safety and enable other clients to trust it. Example use cases are: Core business functionality, Concurrent code, Application containers… (2) Dynamic layer - The dynamic layer is consisting of most the application code. Languages from all the paradigms can be used, as long as they are dynamic and do not require compilation such as Groovy, Clojure and many more. Example use cases are: Rapid web development, Prototyping, Flexible development of functionality, Interactive administrative and user consoles, Scripting… (3) Domain layer - The domain layer is tightly coupled to a specific part of the application and should offer to change rules in production. It can be consist of one or more DSLs (domain specific language) to define the actual domain rules. Example use cases are: Enterprise Integration Pattern modeling, Business rules modeling, Build, Continuous integration, Continuous deployment, Dev-ops… For more detail, you should read The Well-Grounded Java Developer - Part 3.
Groovy
- Java is strongly, statically typed programming language. It is not suitable for all type of use cases. For example, while Groovy may require x lines of code to accomplish some task, Java may require 10x lines of code to accomplish the same.
- Groovy brings high-productivity language features to the JVM including support for static and dynamic programming, scripting, and domain-specific languages.
- You may read my another post about, why Java developer should learn another programming language called Groovy?
Java 5 -> Java 8
- If you are new to Java, you may refer my another post on getting started guide with Java. Anyway the point is that, there are some programming features focused to improve developer productivity with the release of each major version such as...
- Java 5 (Released in Sep 2004) – Generics, Autoboxing, Enhanced for loop, Annotations…
- Java 6 (Released in Dec 2006) – Scripting in the Java Platform…
- Java 7 (Released in Jul 2011) – Project coin features…
- Java 8 (Released in Mar 2014) – includes features for productivity, ease of use, improved polyglot programming, security and improved performance. For example, see sample code authored by Venkat Subramaniam for prior to Java 8 vs. Java 8 way to find square root of first and last numbers of the first 100 prime numbers.
Java EE 7
- Please refer Slide 4 of Boosting Productivity and Embracing HTML5 PPT. Developer productivity is one of the key rubrics of Java EE 7 referring to more annotated POJOs, Less boilerplate code and Cohesive integrated platform. To explore practically, you may refer Java EE 7 samples on Github.
Spring Data
- Provides efficient approach to data access – relational, non-relational, map-reduce and beyond. Its most compelling feature is the ability to create repository implementations automatically, at runtime, from a repository interface.
- See "create simple queries" section to realize accessing data using Spring Data JPA needs just minimal efforts. Or refer DAO (repository) layer in Spring petclinic sample app to see difference in "total lines of code" among Spring JDBC vs. JPA vs. Spring Data implementation approach.
There are many more
technological considerations for writing less code. Anyway to make a long story
short, Java developers should keep upgrading their skills to harness the power
of modern technologies and frameworks for writing code that is more compact,
simpler, and easier to maintain.
Final Thoughts
Every project has
its own architecture and development environment. So all the above-mentioned technical aspects may not be applicable to each and every project. Anyway here
is the crux...
Finally please do share your experience in the
comment, if you know any additional tactic applicable to improve java developer
productivity.
Disclaimer
I am not biased to
particular free or commercial tools and frameworks, rather my objective is
about sharing my own experience on the this topic.
No comments:
Post a Comment