My review on “Java By Comparison” book

Recently I received a print copy of book titled “Java By Comparison” authored by @simonharrer along with two more co-authors. As the book states “become a Java Craftsman in 70 example”, this book is mainly focused on improving your Java coding skills with set of  examples as best practices.

The book is published on March 2018 and available in amazon to buy,


Below are some key features of this book,

  1. Provides best coding practices/ Code quality
  2. Explanation through Examples
  3. What are do’s and don’ts
  4. Usage of Java8 features
  5. Step by step explanation
  6. Easy to read and grasp the content

This book really helpful to novice and intermediate level programming developers in the industry. Even though the book is not a reference for Java experts, it helps in improving some of the commonly ignored practices and covering the edge cases. Finally I recommend this book to programmers(especially beginners to mid-level programmers) who wants to improve on code quality in a quick span of time.

Last but not least, writing code is not a big challenge but writing good-quality code needs lot of efforts, time and passion. Happy reading 🙂



How to detect and avoid cyclic dependencies in javascript

In many programming languages, you might heard about circular dependencies (a.k.a as cyclic dependencies).  But if you are new to this terminology then let me briefly explain what that is, how to detect and how to avoid that in your code.

As per wikipedia “let me briefly explain what that is and why would you prefer to avoid that in your code.”  The below diagram depicts how these circular dependencies related as an example,

Many developers assume that circular dependencies are anti-design pattern and bad design, but they are often required in a complex software application. So if your application contains circular dependency then it doesn’t always imply a bug. In case, when there is a chance of bug or problem then it is developer responsibility to detect and avoid them.

There are two possible options to detect cyclic dependencies in your javascript project

Circular Dependency Plugin: 

This plugin is used to detect circular dependencies when bundling with webpack bundler. The compatible version of this plugin should be used based on webpack version. The latest version5.0 of this plugin  supports webpack 4.x where as  4.0 version supports Webpack 3.x version. Find more details about the npm module here

The plugin is quite mature  and I have been used in one of a Vue project to detect the dependencies. It detected indirect dependencies caused by Vue Router package.

The usage of this plugin is very simple. You just need to import the plugin and configure it similar        to any other plugin.

The customization for cyclic dependencies can be achieved using three callbacks: onStart, onDetect and onEnd. For example, the default messages can be customized by indicating the beginning, cyclic modules path and completion of detecting dependencies as below,

Currently it only provides metrics through messages either in warnings or errors.


Apart from showing the circular dependencies information, it can act as a developer tool for generating a visual graph of your module dependencies. It would be easy to find the dependencies relation in the complex application. Find more details about the npm module here

You can install this package using below npm command,

if you want to generate visual graphs either in SVG or DOT format then you need to install Graphviz software,

Now it is ready to use madge in your application by creating it as npm script. The commands for finding circular dependencies and creating the visual graph for dependencies would be as follows,

The example visual graph of module dependencies would be as below. The red color boxes indicates circular dependencies.

After detecting the circular dependencies, the next step is going to be how to break the cyclic dependencies. You need to move the code snippets to some other sharable file to break dependencies among modules. This might be a time taking process based on type of complexity in the application.

Note: I reported one issue related to dynamic imports support and the fix is available in the latest version.

Conclusion: Even though there are no standard tools or packages available to detect the circular dependencies, both circular dependency plugin and madge package provides flexible API to find out these cyclic dependencies in the large to medium scale applications. I believe that each application should have a check to find out and avoid these dependencies as much in the future.


How to upgrade Angular5 projects to Angular6?

Did you ever feel that it is going to be very difficult to upgrade Angular5 project to Angular6.x version. It might be “Yes” for many developers. Even I faced many errors while upgrading my PrimeNG-Extensions project (https://github.com/sudheerj/primeng-extensions) to Angular6.x version.

If you try to upgrade the Angular6 dependencies manually with in your package.json file and then renaming .angular-cli.json to angular.json, you will get the below error which is not easy anyway to find out the root issue,

This is because the schema will be different for .angular-cli.json and angular.json. Instead you need to follow the below four steps to achieve successful upgrade.

Note: You remove ./node_modules folder before the upgrade. It make sure the correct dependencies  and avoiding compatibility/conflict issues

1.Upgrade your Angular CLI version 

Run the below npm command to upgrade your angular CLI version. This command will update the angular cli version in devDependencies section of package.json file

2.  Upgrade your Angular CLI configuration using npm

Run the below npm command to convert the project configuration file from .angular-cli.json to angular.json file. It will also update unit testing and tslint config files such as karma.config.js, tsconfig.json and tslint.js etc.

3. Update your Angular dependencies

Run the below npm update command to upgrade all your Angular dependencies in package.json file

4. Upgrade third party dependencies

You also need to upgrade older TypeScript version which may not be compatible with latest Angular version. So manually update this dependency from “2.4.2” to latest version( currently it is “2.9.2”). Another important upgrade is RxJS version from “5.5.2” to latest( currently it is “6.3.2”). Other third party dependencies upgrade which depends on your project also should be done based on the usage.



TypeScript: A strict typed language for JavaScript world

TypeScript is a free and open-source typed superset of javascript(in other words ECMAScript 2015) that compiles to plain javascript. So every javascript program is a valid typescript code. The typescript can be used in both client side and server side javascript applications. Actually it is meant for developing large scale applications where you can get the huge benefit of typescript.The typescript compiler itself is written in Typescript code. The static language analysis will bring tooling and IDE support.

There are two ways to install typescript tools

  1. Using npm (a node package manager)

2. Using Typescript’s visual studio plugins

If you are using either Visual Studio 2017 or Visual Studio 2015 Update 3 then it include TypeScript by default. And if you are using older versions then you need to download it separately.

Continue reading


Webpack: A module bundler for JavaScript applications

Webpack is an open-source JavaScript module bundler for JavaScript applications. The bundler can be used from the command line(CLI) or configured using a config file named webpack.config.js. It takes modules with dependencies and generating static assets representing those modules.

Nowadays, Webpack is a leading bundler for Angular, React and Vue frameworks with various templates.  Due to it’s unique syntax who are new to Webpack thinking that it is difficult to configure and using it. But once you are familiar with it’s features then it is very easy to use in all kinds of applications. The current version of webpack is 3.8.1v.

It works with two major goals

  1. Everything treated as a module which includes JS files, CSS files, image files and HTML files. Also each artifict can be divided into smaller and reusable chunks.
  2. Load only the modules which you need on demand. Some of the bundlers combines all of the modules into single big bundle.js file which takes more time for initial load.In contrast, Webpack generates several smaller “bundle” files, which loads some parts of the app asynchronously to improve the page load time.

Continue reading


Lodash: A modern JavaScript Utility library

Lodash is an open source(MIT licensed) modern javascript utility library to ease the programming tasks in a functional programming paradigm. The main goal of this library is modularity, performance and simplicity. This library handles the hard parts of javascript across various types of data such as Arrays, objects, strings, functions, date and so on. This project is inspired by UnderScore utility library.

The module methods are mainly used for

  • Iterating Arrays, Objects and Strings
  • Manipulating and testing values
  • Creating composite functions
  • Creating own mixins for Lodash

The major features of this library are,

  •    Modularity and consistency
  •    Enhances and compatible with ES6/7
  •    Compatible build available for IE8 and older
  •    Available in AMD, ES and CommonJS module formats

Continue reading


Interactive command line interface using InquirerJS

InquirerJS is an easily embeddable and beautiful command line interface for NodeJS projects. I found this library while I was working with JHipster-PrimeNG module. JHipster provides various modules to generate the modern web applications with the help of Yeoman generator. Internally Yeoman generator uses this library for an interactive question and answer prompts through CLI. But we can use this library in a standalone environment as well. Even though there are full blown command-line utilities such as Commander, Vorpal and args available in the market, the usage and benefits of InquirerJS is quite impressive.

The major tasks of this library includes:

  • Asking questions
  • Parsing input
  • Validating answers
  • Providing error feedback
  • Managing hierarchical prompts

Continue reading


My review on Beginning Spring Boot 2.0 Book

In this post I’m going to provide my review comments on  ‘Beginning Spring Boot 2.0’ book written by Siva Prasad Reddy. I know the author of this book very well by working as a technical reviewer for one of his previous book titled “PrimeFaces Beginner’s guide”.  This book is divided into 19 smaller chapters to make the concepts clear. Each chapter explains how Spring Boot makes the life easier in terms of configuration and integration with other technologies when compared to plain Spring based applications. This book covers most of the popular Spring boot starter projects with step by step examples in a simple language. Apart from these spring boot modules, there are some dedicated chapters for security, testing, building RESTful apps, reactive programming,  JHipster generator and  deploying the Spring boot applications.

Continue reading


JHipster meets PrimeNG or PrimeNG meets JHipster

JHipster is an open source application generator used to develop modern web applications and microservices using Angular and Spring framework. The tool generates Java stack on the server side(Spring Boot) and responsive front-end(Angular) on the client side. JHipster 4.0 supporting Angular2 and after that JHipster 4.2 supported Angular 4 versions. It can cover more scenarios if it supports any popular Angular component library. Currently PrimeNG is one of the most popular component library in Angular community with 85+ components categorized under 8-9 groups. Also, the components look and feel can be changed with the help of around 20 themes available.

JHipster-PrimeNG module enables PrimeNG support with an easy setup similar to any other JHipster module. Initially it supports interactive theme selection and component groups to generate customized application.

The Github project is available here

Continue reading


What’s new in PrimeNG 4.2 release

After two months, PrimeNG released 4.2 version with some new features and around 200 defect fixes. The notable features are rewrites for Terminal using service, Message service for Growl and messages, button bar(Today and Clear buttons) and date template for Calendar component, item template for MultiSelect, loading indicator for DataTable and autoComplete components and floating feature for input components and so on.

Some of the major features are as follows,

Continue reading