Skip to main content


Showing posts from July, 2012

Mustaches in the world of Java

Mustache is templating system with implementation in many languages including Java and JavaScript . The templates are also supported by various web frameworks and client side JS libraries.

Mustache has simple idea of "logic-less" system because it lacks any explicit control statements, like if, else or goto andalso it does not have for statement however looping and conditional calculation can be achieved using custom tags that work with lists and lambdas.

The name unfortunately has less to do with Tom Selleck but more with the heavy use of curly braces that look like mustache. The similarity is more than comparable.

Mustache has implementation for most of the widely used languages like:  Java, Javascript, Ruby,Net and many more.

The client side template's in JavaScript Let say that you have some REST service and you have created a book view object that has an additional function that appends amazon associates id to the book url:

var book = { id…

Google Guava for cleaner code

Some time ago I did a short talk on Google Guava for our local JUG. It was a basic intro into Guava and how it makes stuff simpler, better and cleaner.

It is true that there is an overlap with Apache commons but Guava is build with expectation that there is a Function and a Predicate class as well as various builders which makes it really cool and simple for many use cases.
The talked covered most of the* classes  and basic use of functions in collection and Google collections  and few other features that are part of Guava and I find them very useful.
Source code of the examples can be found on github and here is the actual presentation:
Google Guava for cleaner code
Note one last recommendation that is not just mine but  also part of Guava's wiki :
Excessive use of Guava's functional programming idioms can lead to verbose, confusing, unreadable, and inefficient code. These are by far the most easily (and most commonly) abused parts of Guava, and when…