Java 9 : Collections factory methods

As of Java 8, there's  no simple or single statement way of creating collections with a small number of elements. In scenarios like unit tests where a Set of Strings are to be created as mock data,  it is needed to create a new Set and start repeatedly adding the elements which is highly verbose. Java… Continue reading Java 9 : Collections factory methods

Different ways of String formatting in Java : Benchmarking

Java programmers use mostly the following three ways for formatting or building a string. String concatenation using + operator Using String.format Using StringBuilder Functionally all these 3 ways will produce the same result but the question is "are all the 3 ways have the same time and space performance?". I wrote small code snippet to… Continue reading Different ways of String formatting in Java : Benchmarking

JUnit Practices 1 : Let the Tests Talk

Each variant of the assertion in JUnit has a distinct purpose, used in a right context the assertions yield useful information on test failures. It is possible to construct tests with an assertion that is intend for a different purpose and make it work as expected; when we do so we may possibly loosing the… Continue reading JUnit Practices 1 : Let the Tests Talk

Handling unused imports in Eclipse

The following three ways can be used to fix the unused imports in Eclipse If you have a file or two with unused imports, open the file that has unused imports and use ctrl+shift+O, this automatically organizes the imports; removes unused and adds any missing imports Avoid unused imports by enabling the organize imports option… Continue reading Handling unused imports in Eclipse

Stop writing obvious code for POJOs, use lombok’s @Data

Lombok helps in getting rid of the obvious code that we write when we define a class, instead it generates the obvious code at the time of compilation. Lets say if you are writing a plain vanilla bean to define a Car that has three attributes make, model and year you will define a class… Continue reading Stop writing obvious code for POJOs, use lombok’s @Data

Schema-less, Not model-less

The data model is not just the model of the data base tables, it represents more than that. Data model represents the domain model; the various entities that represents the a business. For  any product to be successful and to serve the intend purpose the data model is important, the data model is the common… Continue reading Schema-less, Not model-less