Multiplication wheel - Interesting project for teaching multiplication to kids.

In this post, I will share an interesting project we can do with our kids to teach them basics of multiplication and introduce them to programming. I did this with my 5-year-old daughter and it was a huge hit.


Continue reading...

Highlights from Book Succeed - How We Can Reach Our Goals

In this post, I will share my highlights from the book Succeed : How We Can Reach Our Goals which I recently read.

We all have goals, but we don’t have an understanding of why we achieve some of them and fail on others. This book is about understanding how goals work, what tends to go wrong, and what you can do to reach your goals.


Continue reading...

Java 8 automatically injecting logger using trait

This post explains how default methods in Java 8 can be used as a trait to automatically inject logger instances.

To use logging in Java code, we need to add this boiler plate code in every Java class.

private static final Logger logger = Logger.getLogger(MyClass.class.getName());

Like me, most of you would hate copy pasting this line and updating the class name in every Java file. Luckily, Java 8 supports default methods in interfaces which can be used to solve this problem.


Continue reading...

Error accumulation in validation using Applicative Functors

This post explains how Applicative Functors can be used accumulate validation errors using Javaslang validation API.

Problem

To illustrate with an example, let’s say a given stream of pair of date strings in format MM/dd/YYYY, we want to print difference between them in number of years, months and days. ( For eg "01/01/2016 , 02/01/2016" should print 0 years , 1 months and 0 days).


Continue reading...

Better Exception Handling in Java 8 Streams Using Javaslang

In this post, I will provide tips for better exception handling in Java 8 streams using Functional Java library Javaslang.

Problem

To illustrate with an example, let’s say we want to print day of the week for given stream date strings in format MM/dd/YYYY.


Continue reading...