Sunday 8 March 2015

Tactics to improve Java development productivity

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.

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.
  • 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
  • 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.

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.
  • 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 5 -> Java 8
  • 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 EE 7

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.

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