If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Friday, April 4, 2014

Ceylon: annotations

What is an annotation?

An annotation is a top level function that returns a subtype of ConstrainedAnnotation.

There are 2 interfaces which satisfy ConstrainedAnnotation directly:
  • OptionalAnnotation: An annotation that may occur at most once at a single program element and only on certain program elements.
  • SequencedAnnotation: An annotation that may occur multiple times at a single program element, and only on certain program elements.

Let's see the type hierarchy of ConstrainedAnnotation to get a better picture.

So what you might have thought to be reserved keywords (shared, formal, actual, ...) are in fact annotations used by the compiler.  Let's see how the DocAnnotation is implemented.

Wednesday, April 2, 2014

Using Java's FutureTask to execute Callable tasks concurrently

In this demo we have 2 Case Providers, one for Activiti and one for WPS. I used Thread.sleep to mimic a time consuming computation (e.g. IO). Now we want to have a composite Case Provider which composes cases from both case providers. However, as we naively implement this in SequentialCaseProvider we will see that the total time it takes is the sum of having the 2 caseproviders fetch the cases (9 seconds). By using a concurrent approach in ConcurrentCaseProvider, we can reduce the time to +- the time it takes the longest CaseProvider to fetch the cases. (5 seconds)

Friday, February 28, 2014

Java, Immutability and Builders

When you have to work with complex nested object structures and you want an easy way to create them and test them, I think it's definitely worthwhile to create a builder. A builder is a fluent DSL to create (domain) objects. Below you can see how that works out

Wednesday, January 29, 2014

Code puzzler: Tape Equilibrium

Suppose you get an array of ints of arbitrary length. Now we need to find out what is the mimimal absolute difference of the 2 sums of numbers if you split the array at any position in a left and right array. And preferably in a efficient way.

Friday, January 10, 2014

AxonFramework - initial exploration

For the record, this demo is kind of copied from the quickstart but it is in some ways more elaborate and using the latest and greatest version 2.0.7
Now we start thinking about the behaviour of our little demo application. A user can create a new todo item and he can mark an existing item as completed.
When commands are issued, something is bound to happen, so we also need to think about what events occur.
We also need to think about our aggregate, in this case our ToDoItem
Of course we need to test if events are properly created when a command is issued.
We also need to configure the application, as usual we will use Spring to wire our app.
The demo app just issues 2 commands, mimicking what a user might do. And to make it interesting we also create an event handler for our ToDoItem events.
When we run the ToDoApplication we notice a file gets created in c:/tmp/axondemo/ for our aggregate called TODO-1.events. Also we nicely see some output appearing in the console:
We've got something to do: Clean house (TODO-1)
We've completed a task: TODO-1

Friday, January 3, 2014

Caching - the pitfall

At a current project we added some caches to our application to improve performance. However, we faced some issues I looked into and this article will demonstrate you should use caches with great precaution.