Showing posts with label Tools & Techniques. Show all posts
Showing posts with label Tools & Techniques. Show all posts

Sunday, 11 June 2017

Java power tools series - Executive diagram

I hope, you have already read "Preface" of my java power tools series.

In this blog, I just thought to publish my one of old mind mapping diagrams (not updated in last 2 years). I think, following java tools classification view should be effective and useful to others' for quick reference.

(Right click the image - Open in New Window - Zoom it)


Please share your experience in comment, if you have something to add / update with respect to following outlined java tools blueprint.


Disclaimer

I am not biased to particular free or commercial tools, rather my objective is about sharing my own experience on set of tools. 

Sunday, 30 April 2017

WireMock - A simple standalone HTTP server for service virtualization

I hope, you have already read "Preface" of my java power tools series. In this post, I intend to introduce WireMock tool.

Straight from the horse's mouth

  • Mock your APIs for fast, robust and comprehensive testing using WireMock (a simulator for HTTP-based APIs /  service virtualization tool / mock server)
  • Enables you to stay productive when an API you depend on doesn't exist or isn't complete
  • Supports testing of edge cases and failure modes that the real API won't reliably produce
  • Features = HTTP response stubbing, request verification, proxy/intercept, record/playback of stubs and fault injection
  • Flexible deployment options - run it from within your Java application, JUnit test, Servlet container or as a standalone process
  • Powerful Request Matching - Match request URLs, methods, headers cookies and bodies using a wide variety of strategies & first class support for JSON and XML
  • Record and Playback - Get up and running quickly by capturing traffic to and from an existing API

My Personal Feedback

I witnessed that WireMock's is extremely easy to setup and harness.  This tool can benefit appreciably in MicroServices Architecture. Let me explain two scenarios, where I could take advantage of WireMock.

(1) Create quick prototypes of REST APIs

Many times, services are not implemented by REST server apps or made available by external vendors. Still, there is a pressing need to develop REST client app beforehand, may be for demo purpose or meeting deliverable goals or due to any other business need. Well, WireMock can help here to create prototypes of agreed APIs quickly, which can be consume by client apps even without realizing these are stubbed APIs instead of real. See running wiremock as a standalone process option.



(2) Record real external services and playback

At times, client app needs to consume third-party or external services over internet or network. However, there are frequent connectivity issues or high latency problem or only limited requests are supported per day due to chargeable services, specifically while accessing these services in Development. Obviously, this may result in high developer productivity loss. Well, WireMock has unique ability to record real services (requests and responses) without a need of single line of coding and playback those in even offline mode automatically. WireMock's this record/playback of stubs feature can greatly boost developer productivity. See record and playback option.


Other scenarios you might want to consider WireMock for:
  • Testing mobile apps that depend on third-party REST APIs
  • Injecting otherwise hard-to-create errors in 3rd party services
  • Any unit testing of code that depends on a web service

All in all, WireMock is a Java-based flexible library with a JSON API that can be used to virtualize, mock, and stub web services.

Try WireMock Practically

Now let's understand fundamental ability of WireMock by running it as a standalone HTTP server and stubbing web services. Let's see practically how effortless it is.

ABC of WireMock standalone server


To POST data to WireMock's REST endpoint (i.e. http://localhost:9999/__admin/), you can use curl or postman tool or any other choice of tool.

  • Start wiremock as a standalone server:  java -jar wiremock-standalone-2.6.0.jar --port 9999 --verbose true
  • This would create "__files" and "mappings" folders (in the same folder where wiremock jar exists) to store stubbed services. To see what all service stubs exist on WireMock server (within "__files" and "mappings" folders), open admin console in browser: http://localhost:9999/__admin/
  • To stop wiremock, just kill the process or post a request with an empty body to this REST endpoint: http://localhost:9999/__admin/shutdown
  • For more detail, see @ http://wiremock.org/docs/running-standalone/.


Stubbing Services / Create REST APIs Prototypes

A core feature of WireMock is the ability to return canned HTTP responses for requests matching criteria. These criteria can be defined in terms of URL, headers and body content.


Record external services and Playback

WireMock has the ability to create stub mappings by recording them while you send requests. This can be used to quickly capture a collection of responses from a real service then use them offline in your tests.
For Example, run this command to record and playback Github Developer APIs:

For any requested REST service request (i.e. http://localhost:9999/users/tirthalpatel), first of all WireMock would check, if corresponding stub mapping exists in "mappings" folder or not. If existing, then don't hit real service rather serve recorded data from "mappings" and "__files" folders. If not existing, then WireMock calls external real service (i.e. https://api.github.com/users/tirthalpatel) followed by records stub mapping followed by returns response to the client. That means, we can expect WireMock to playback all recorded stub mappings even if internet is unavailable.



The above explained and few more examples, you can find @ https://github.com/tirthalpatel/Learning-Tools/tree/master/gs-wiremock


Also See

Disclaimer

I am not biased to particular free or commercial tools, rather my objective is about sharing my own experience on set of tools. 

Sunday, 19 June 2016

Java power tools series - Performance Analysis

I hope, you have already read "Preface" of my java power tools series. Actually, I was intending to write detailed separate posts on numerous performance diagnostic tools, like I wrote few posts previously as part of this series. Anyway, let me start with quickly recollecting my knowledge on this topic.

Well, performance analysis and optimization is indeed not a child's play. At times, it may be a hard nut to crack for developers, specifically when performance problem is reported by a client in production environment and not replicated in testing or development. In fact, scalability issue is reported as performance issue sometimes, which can be solved by vertical or horizontal scalability instead of unnecessarily spending time in code analysis and optimization activity. Likewise, always performance issue could not be triggered by faulty code, rather there could be inefficient application server or JVM tuning issue! You never know. Therefore, there has to be a thoughtful architectural strategy to accomplish application's performance requirements or for troubleshooting and fixing reported performance problems. Well, Performance Engineering, Benchmarking, Software Performance Testing, Performance Tuning and Java Performance are vast topics by own. So, let me restrict this blog primarily for listing java application performance monitoring, profiling and analysis tools.

Few remarkable tools for performance analysis of Java applications


Problem Statements
My Preferred Tool / Product / Solution
Pricing Remark
Related References
I am damn sure, there are memory related issues. Just need to find memory leaks and reduce memory consumption via memory dump analysis.
Free
 
Just need to analyze java thread dumps.
Free
For non-production environment, need visual interface for Java monitoring and troubleshooting tool, which should provide some basic profiling capabilities too. (may use in production, if performance overhead is not a critical concern!)
Free
Looking for modular and extensible web console, which can be used to manage every kind of container or even any JVM middleware.
Free
For production environment or complex performance troubleshooting needs in non-production environments, need advance Java Profiling tool. Needless to mention, such tool's performance overhead should be minimal or even controllable.
Commercial

(Oracle JMC and JFR requires to purchase license for production use, otherwise it's Free.)
Need of APM solution for Business transactions profiling, root cause detection and performance diagnosis in Development or Test Environment for single JVM or an application. Just limited freely offered "Java performance monitoring with automatic root cause detection" features may be sufficient to find a performance bottleneck. (may use in production for simplistic requirement)
Free

(limited features available compare to commercial offerings)
* All in All, looking for adopting full-fledge Application Performance Management (APM) solution for production, and apparently should work for distributed systems by providing a visual dashboard to manage multiple JVMs across different machines.
* The performance issue is reported in production, but not able to replicate in Development and QA environments, so all are at their wit's end to find the bottleneck in the system! Need to troubleshoot problem directly in production with negligible overhead!

* Java profiling tool is not sufficient for performance analysis. Because performance issues are occurring unexpectedly in production systems and exact business transaction or bottleneck is unknown, which is causing the issues! It could be even Database or external Web Service or Scala component!
Pressing business requirement to discover, diagnostic and resolve application issues before they impact end users, violate SLA or negatively impact the business.
* Need a complete solution to monitor various components of the application and technology stack, such as server, database, hardware, network. In fact, looking for an automated capability in production to identify problematic transactions based on performance thresholds and offer centralized business intelligence like dashboard.
Commercial

(for real production purpose, all are commercial. Most offers SaaS pricing model. Although, some offers On-Premise and Hybrid deployment options too)

The Performance Tuning Lifecycle


If you are newbie to Java performance tuning area, then I strongly suggest to attend less than 2 hours Complete Java Performance Tuning Training course on youtube for fundamental understanding on the following performance tuning lifecycle. Then, you can proceed to choose suitable tools to identify performance bottleneck.
  1. Define Requirements
  2. Measure / Test (Create Baseline)
  3. Identify Bottleneck
  4. Implement Fixes
  5. Measure / Test (New Baseline)
  6. Compare to Old Baseline & Requirements
  7. If necessary repeat steps 3 – 6

Performance Troubleshooting Tools Highlights


You may attend an hour presentation on "Troubleshooting Live Java Web Applications", which I found very informative for the performance troubleshooting tools scoping in production vs. development environment. Specifically at the end of the presentation below final tools comparison chart provides outstanding information.


Also Refer


Disclaimer

I am not biased to particular free or commercial tools, rather my objective is about sharing my own candid experience on set of tools.


If you know or have experienced any other tools suitable for Java applications performance analysis, please share the name of such tool along with your personal feedback in the comment.

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. 

Sunday, 25 January 2015

Java power tools series - Extra plugins to enrich Eclipse IDE

I hope, you have already read "Preface" of my java power tools series.

I love using Eclipse, but it is perturbing to upgrade it. Because every time we need to install numerous extra plugins to enrich its standard ability. Besides this, we need to recollect what all plugins to be installed in new Eclipse version. So I thought to publish a post to list Eclipse plugin names which I rely on regularly or occasionally for my own future reference. I hope below Eclipse plugins listing may benefit other java developers too.

Eclipse Plugins


Free
Commercial
Development
Liferay IDE - for building plugins for the Liferay Portal 
for developing Spring applications & GGTS for developing, debugging and executing Groovy and Grails applications
JBoss Tools - like Hibernate Tools provides tooling for JPA and HQL
Plugin for Groovy - provides Eclipse support for Groovy projects
Scala IDE - provides advanced editing and debugging support for the development of pure Scala and mixed Scala-Java applications
AngularJS - Eclipse plugin for AngularJS projects

Unnecessary Code Detector - Dead code analysis
FindSecurityBugs, LAPSE+ - Code security analysis

Unit testing and Code Coverage
Infinitest - Greatly works with TDD. Each time a change is made on the source code, Infinitest runs all the tests that might fail because of these changes.
MoreUnit - Shortcuts to switch between tests and classes under tests, create test stubs, mock support, decoration, refactoring support
EclEmma Java Code Coverage - a Java code coverage tool for Eclipse

Productivity
InstaSearch - fast text search in the workspace
Eclipse Code Recommenders + Snipmatch - code recommendation and a snippet completion engine
MouseFeed - Helps to form a habit of using keyboard shortcuts
JAutodoc - For automatically adding Javadoc and file headers to your source code
JRebel - Live code reload.  Eliminates need to build your app to see changes
Diagramming and Reverse Engineering
Diver, Jive - Runtime sequence diagrams generation
ObjectAid - Reverse engineering for class diagram generation
ModelGoon- Generate various UML diagrams from code
BundleMaker - Dependency analysis
Maintainj - Runtime sequence and class diagrams generation and debugging
Architexa - Generate layered, class and sequence diagrams from code
Performance Analysis
Java Mission Control - A set of plugins designed to help develop, profile and diagnose applications running on the Oracle Java HotSpot VM
VisualVM - for monitoring and profiling of java applications
Lockness - Java thread dumps analysis
MAT - Java head dump analyzer

Miscellaneous
JD-Eclipse - Java decompiler
EasyShell - Offers tight integration of system file manager (Windows Explorer, Gnome Nautilus, KDE Konqueror, Mac Finder, ...) and shell (cmd.exe, Linux/Mac terminal) in Eclipse
Eclipse-fonts - Increase/decrease font-size in editor
AnyEdit Tools - Convert, compare, sort etc.


Updates History
  • 20/May/2017 - Added Infinitest for unit testing


If you know or have experienced any other outstanding Eclipse plugin, please share the name of the plugin in the comment.

Disclaimer
I am not biased to particular free or commercial tools, rather my objective is about sharing my own experience on set of tools.