Tom McAdam

minimalist java: an update

It’s been a while since we wrote about Minimalist Java. A lot has changed since then, so today I’m going to give you a quick update on how things have evolved.

Minimalist Java is our approach to writing Java, trying to keep ourselves sane whilst doing so. Java can be a beast but can, with a sprinkling of the right libraries and techniques, be tamed into something quite elegant. Effective Java still has pride of place on the bookshelf, and other—language-agnostic—approaches such as dependency injection and the Single Responsibility Principle are at the core, of course.

java 8

In that time, the biggest change has been the release of Java 8. This has introduced some of our much-loved features from Guava to the core language. Functional idioms such as the Predicate and Function are now first-class concepts in the language. Combined with streams, we get incredibly succinct and readable collection manipulation.

Other self-documentation aids like Optional have made it, too. Last but not least in language improvements must be the introduction of a sane date library in the form of java.time.

We’re gradually moving over to using these new features, but mainly in new projects just now since having Java 8 and Guava functional idioms or Joda dates co-exist is somewhat painful.

dropwizard

We spend a lot of time writing APIs in Java. More and more of that is in microservices, so anything we can do to reduce the overhead of doing so, the better. We’ve recently started using Dropwizard for that reason. Out of the box you get a bunch of sensible libraries to give you that leg-up when starting something from scratch. Not to mention the metrics and health checks.

We already had many of these things in our own shared libraries, but having them brought together all under one roof integrated in a pleasant fashion meant we could ditch a whole bunch of custom code.

front-ends

We’ve also moved away from using Closure templates in favour of completely separating out front-ends from APIs. This has led to cleaner and more flexible APIs, since we have to invest time up-front thinking about them. It also means we’re able to do front-end changes without needing to deploy API servers.

TODO

Our approach is constantly evolving, and we’re currently looking at what to do with dependency injection, and whether we even need a DI framework with small microservices. If we do, Dagger is top of the list right now for just-about-enough-but-not-too-much-magic.

Of course, closely related to our Java engineering approach is our approach to running all of this. As readers of this blog will know, we’ve been looking at moving to containers to simplify and streamline everything. More on that soon.

How do you tame Java? Why not pop along to next month’s #MetaBeers on 14th October to tell us.

If you enjoyed the read, drop us a comment below or share the article, follow us on Twitter or subscribe to our #MetaBeers newsletter. Before you go, grab a PDF of the article, and let us know if it’s time we worked together.

blog comments powered by Disqus