9 Design Patterns Translated Into Java 8’s Lambdas

LAMBDAS!

There’s been a lot of hype around lambdas getting introduced in Java 8, and I have a good theory on why: hype is often born out of anticipation, and we’ve been anticipating lambdas in Java for a LONG time.

Lambdas?

A lambda spray paint pattern, the same design as in Half-LifeThe funny thing is that lambdas don’t, by themselves, do anything new. They’re just a succinct form for turning a block of code into an object that can be passed around – syntactic sugar. Some of us have been doing this for a while without the succinctness and we call it… object-oriented programming! Yes, passing blocks of code (aka functions) around as objects (aka values) is also core to functional programming, but certainly not unique to it.

Patterns!

Somewhere that this idea of “passing code around” is heavily utilised is in Continue reading

RxJava Threading Examples

I recently used RxJava while creating an add-on for Stash, the Git repository management tool from Atlassian. The plugin’s called “Who’s the Expert?” and it analyses commits to a repository to help answer two questions:

  1. “Who has contributed the most to this project over the past few years?” and
  2. “Who has made the most significant changes in recent months?”

A Problem Worthy of RxJava’s Attention

This picture of water drops on the threads of a spider web reminded me of the bubble diagrams the RxJava team uses to explain how values move through the libraryIn order to achieve this, the plugin has to process a lot of data: it pulls all commits on the default branch for the last 2.5 years and analyses the content of every single one. I knew two things about this code in advance: first, there were going to be a lot of steps to go from a repository name to a leaderboard of the most influential committers, and second, I was pretty certain I’d need some multi-threading mojo in order to get it to perform in an acceptable time frame.
Continue reading