op4j: Bending the Java spoon

The tagline of op4j is very interesting: ‘Bending the Java spoon’, which implies that the library offer magic to Java programming. And indeed it does.

The basic idea of the library is to use Fluent Interface to a much greater use. To do this, the developer basically try to provide as much general functions as possible. It says that the current version of op4j has already more than 1000 functions.

If you read some examples from the website and from the blog, you can find several absolutely genuine idea how programming with Java can be enjoyable. One example:

Calendar date = Op.onListFor(1492, 10, 12).exec(FnCalendar.fieldIntegerListToCalendar()).get();

which if done without op4j will be something like:

Calendar date = Calendar.getInstance();
date.set(Calendar.DAY_OF_MONTH, 12);
date.set(Calendar.MONTH, Calendar.OCTOBER);
date.set(Calendar.YEAR, 1492);

Although on this particular case I can see some people will say that the first code is unclear because there the order of the integer can somehow confusing the reader, the fact that it saves a lot of program code is absolutely beautiful.

I love the fact that lately there are many Java libraries with a goal to make programming much enjoyable.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.