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

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

What’s up with JUnit 5

JUnit 5 is not yet a GA release but it has started making the buzz around with its all new features, especially the Java8 enthusiasts like me couldn't wait for the GA release to start using. Architecturally Junit 5 is a whole different animal than its predecessor; I will not talk about the architecture in this… Continue reading What’s up with JUnit 5