Kotlin collection sequence stream lazy evaluation

Kotlin, collections and sequences

When streams were added to Java 8, I wanted to jump on the bandwagon. I read blog posts, watched videos, attended workshops to understand what this was all about. After a while, I became comfortable enough…​ but I was unhappy with the implementation: while streams offer methods with a functional approach, legacy collections do not. When one wants to use Java capabilities on an existing collection, the later needs to be transformed to a stream, and then back again. For example, the f

Clojure sequence stream

Feedback on Learning Clojure: comparing with Java streams

This is the 7th post in the Learning Clojure focus series. Coming from a Java background, I’m currently trying to learn the Clojure programming language, with the help of online resources and mentorship. Some weeks ago, I tried to wire things together by trying to find equivalent methods to those available in Java streams. While I managed to get things working, writing working code and writing idiomatic code are two very different things. I was fortunate to have a good degree of feedback fr

builder design pattern state machine

The Builder pattern is a finite state machine!

Some weeks ago, I read the post referenced in a tweet. In short, the article provides two ways to generate the boilerplate code required by the Builder pattern: Lombok, to generate code at compile time and the Spark Eclipse plugin, to generate code at development time. However, I already wrote about the Builder pattern. And it’s a bit more complex than what’s described in the referenced post.

annotations reflection vaadin

Listing annotated classes in Java EE

The Java EE platform is huge, and I must confess I’m not aware of every one of its API. This is also true of the Spring framework, even though I think I know more of Spring than of Java EE. Lately, I was working on the version 10 of the Vaadin framework also known as Vaadin Flow. This version introduces routes. When a path is requested, the Vaadin Servlet displays the component. Routes are created by annotating specific components with the @Route annotation. Thus, Vaadin needs to list all a

Clojure dependent types programming by contract

Learning Clojure: dependent types and contract-based programming

This is the 5th post in the Learning Clojure focus series. While describing how to cope with dynamic typing, we used the spec library. The library is not a true replacement for types - checks are executed at runtime instead of compile-time. On the flip side, it can go further than mere types, including emulating dependent types and programming-by-contract.

API JDK design Cloneable

Cloneable, a Java design gotcha

Some time ago, I described a couple of surprising design choices in the JDK functional interfaces API. Lately, during a lesson, a student of mine proposed to shallow-copy an ArrayList by using the clone() method: I thought this is another API gotcha worth writing about. Cloning an object means a new object is created with the same state as the original one. As per the JavaDoc: Creates and returns a copy of this object. The precise meaning of 'copy' may depend on the class of the object.

Clojure specifications type

Learning Clojure: coping with dynamic typing

This is the 2nd post in the Learning Clojure focus series. My new position requires me to get familiar with the Clojure language. In intend to document what I learn in a series of posts, to serve as my personal reference notes. As a side-effect, I hope it will also be beneficial to others who want to take the same path. There are already a multitude of great tutorials available: hence, each post will focus on a specific theme, that is specific to Clojure considering that most of my experience com