Home » Archives for Tomasz Linkowski

Author Archives: Tomasz Linkowski

Tomasz is an enthusiast of clean coding and software craftsmanship, who is particularly interested in problem domain modeling & API design

5 Refactoring Principles by Example

This post features five (mostly well-known) refactoring principles applied when refactoring real open-source code (Gradle Modules Plugin). Context When I worked on separate compilation of module-info.java for Gradle Modules Plugin (PR #73), I noticed potential for some refactoring. As a result, I filed issue #79 and later resolved it with PR #88 (not merged yet), where I refactored the code. ...

Read More »

Building Java 6-8 Libraries for JPMS in Gradle

Find out how to use Gradle to build Java 6-8 libraries that support JPMS (Java Platform Module System) by providing Java 9 module-info.class. Introduction If you need introduction to JPMS itself, check out this nice overview. This post is primarily targeted at Java library maintainers. Any such maintainer has to make a choice of which JDK to target: Targeting the ...

Read More »

Accumulative: Custom Java Collectors Made Easy

Accumulative is an interface proposed for the intermediate accumulation type A of Collector<T, A, R> in order to make defining custom Java Collectors easier. Introduction If you’ve ever used Java Streams, you most likely used some Collectors, e.g.: Collectors.toListCollectors.toMap But have you ever used… A composed Collector? It takes another Collector as a parameter, e.g.: Collectors.collectingAndThen.   A custom Collector? ...

Read More »

Filterer Pattern in 10 Steps

Filterer is a pattern that should be applied only in certain cases. In the original post, I presented a very simple example intended to show howto apply it. In this post, I present a much more detailed example that’s intended to also explain when and why to apply it. Introduction The post consists of the following 10 short steps. In each step, I introduce requirements of the following two types: ...

Read More »

Transformer Pattern

The Transformer pattern is a design pattern for Java (and potentially other OO languages with use-site variance only and invariant parameter types) that helps objects within a subtype hierarchy fluently transform themselves into objects of any type. Context I was following the OpenJDK threads (Sep 18-21, Nov 12-13, Nov 13-30, Dec 3-4) related to issue JDK-8203703 by Jim Laskey, and an idea came to my mind. Let ...

Read More »