We all as Java programmers been through the situation where in we invoke a method to get some value and then instead of directly invoking some methods on the return value, we first have to check that the return value… Read More ›
java 8
Strategy Pattern using Lambda Expressions in Java 8
Strategy Pattern is one of the patterns from the Design Patterns : Elements of Reusable Object book. The intent of the strategy pattern as stated in the book is: Define a family of algorithms, encapsulate each one, and make them… Read More ›
Creating Internal DSLs in Java, Java 8- Adopting Martin Fowler’s approach
Currently I am reading this wonderful book on DSLs- Domain Specific Languages by Martin Fowler. The buzz around the DSLs, around the languages which support creation of DSLs with ease, the use of DSLs made me curious to know and… Read More ›
Factory Method pattern in Java
In my previous post about the Template Method pattern, I showed how one can leverage lambda expression and default methods. In this post I will explore about factory method pattern and see how one can leverage method references, another feature… Read More ›
Train Wreck Pattern – A much improved implementation in Java 8
Venkat Subramaniam at a talk today mentioned about Cascade Method pattern or Train Wreck pattern which looks something like: someObject.method1().method2().method3().finalResult() Few might associate this with the builder pattern, but its not the same. Anyways lets have a look at an… Read More ›
Converting a List into comma separated value string in Java
We all have at least once in our coding life time done this: “Concatenate the elements of a List into a comma separated string”. And each time we have spent some time figuring out how to do it or sometimes… Read More ›
A simple application of Lambda Expressions in Java 8
I have been trying to fit in lambda expressions in the code I write and this simple example is a consequence of the same. For those totally unaware of Lambda Expressions in Java, I would recommend them to read this… Read More ›
Template Method Pattern- Using Lambda Expressions, Default Methods
Template Method pattern is one of the 23 design patterns explained in the famous Design Patterns book by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. The intent of this pattern is stated as: Define the skeleton of an… Read More ›
Arrays.sort versus Arrays.parallelSort
We all have used Arrays.sort to sort objects and primitive arrays. This API used merge sort OR Tim Sort underneath to sort the contents as shown below: This is all done sequentially, even though merge sort uses divide and conquer… Read More ›
Supplier interface in java.util.function package in Java 8
In my previous posts I wrote about Predicate, Consumer and Function interfaces. In this post I will write about Supplier interface with which I will conclude the description of the interfaces in the java.util.function package. Though there are many other… Read More ›