JDriven Blog

Groovy Goodness: Create YAML With YamlBuilder

Posted on by  
Hubert Klein Ikkink

Groovy 3 adds the YamlBuilder class to create YAML output using a Groovy syntax. The YamlBuilder is closely related to JsonBuilder that is described in a previous post. We define a hierarchy using a builder syntax where we can use primitive types, strings, collections and objects. Once we have build our structure we can use the toString() method to get a string representation in YAML format.

In the following example we use YamlBuilder to create YAML:

Continue reading →

Groovy Goodness: Calculate Average For Collection

Posted on by  
Hubert Klein Ikkink

Groovy 3 adds the average method to collections to calculate the average of the items in the collections. When the items are numbers simply the average is calculated. But we can also use a closure as argument to transform an item into a number value and then the average on that number value is calculated.

In the following example code we use the average method on a list of numbers and strings. And we use a closure to first transform an element before calculating the average:

Continue reading →

Java Joy: Turn A Pattern Into A Predicate

Posted on by  
Hubert Klein Ikkink

This week at work a colleague showed a nice feature of the Pattern class in Java: we can easily turn a Pattern into a Predicate with the asPredicate and asMatchPredicate methods. The asPredicate method return a predicate for testing if the pattern can be found given string. And the asMatchPredicate return a predicate for testing if the pattern matches a given string.

In the following example code we use both methods to create predicates:

Continue reading →

Look to learn and don't think in ink

Posted on by  
Jasper Bogers

The book The Fifth Discipline by Peter M. Senge landed on my doormat recently. I ordered it after hearing Andrew Harmel-Law of ThoughtWorks mention it at the JFokus 2020 conference (article in Dutch). His takeaway was as follows:

"Placed in the same system, people tend to produce the same results".

Once I received the book however, a line at the top of the cover caught my eye:

"In the long run, the only sustainable source of competitive edge is your organization’s ability to learn faster than its competitors"

This statement rings so many bells I’d like to dwell on just that without even going into the book itself. There are two obvious yet often missed clues here that I’d like to share.

Continue reading →

Agile rewrite of an existing system

Posted on by  
Jasper Bogers

The times I’ve worked on a project where the scope is "rebuild the existing implementation, but with new tool / techonology X", I’ve encountered various pitfalls that make these projects much harder than they need to be.

Let me offer some tips on how to deal with them.

Continue reading →

DDD Europe 2020

Posted on by  
Danny Kruitbosch

Last week, on Thursday 6th and Friday 7th of February, I attended DDD Europe 2020 in Amsterdam. In this post I will give a short overview of the talks and workshops I followed and some of my personal takeaways.

I had a great time on the conference. One of the things I like most is the mixture of talks and workshops. In the 2 hour workshops you are expected to actively participate in whatever is happening. Be it discussions or really doing some coding or testing.

I’d like to thank all the speakers and attendees for their input, talks, workshops and discussions during the breaks.

Continue reading →

Kotlin Exposed - aggregate functions

Posted on by  
Christophe Hesters

SQL allows you to do calculations on columns over multiple rows using aggregate functions like COUNT, SUM, AVG etc. This post explains how to use them in Kotlin Exposed. We will also cover arithmetic operations on one or more columns. If you haven’t used Kotlin Exposed before, you can go here for an introduction.

Consider an application containing two tables in an SQL database: Comment and User. A comment is written by a user, and can receive likes/dislikes. The snippet below shows the table definitions:

Continue reading →

shadow-left