Skip to content

René Link

I'm a software developer since 2002 and founded my company Link Intersystems in 2011. My favorite programming language is Java, but I m also experienced in other languages. I focus on design and architecture of java enterprise applications with spring, hibernate or jee. Software quality and therefore clean code belong to my basic principles. ---- If you want others to take you seriously, than take your craftsmanship seriously - be a professional ---- Visit me on careers 2.0 and follow me on stackoverflow.com

How to migrate dbunit data sets?

I often use DBUnit when it comes to integration tests related to the database. DBUnit is a lovely tool to setup a database for integration tests, but it also has a downside: “As more tests you write, more files need to be changed in case of a database schema change“. Wouldn’t it be nice if there would be a tool support, a tool that just scans your project, collects all the data sets it finds and migrates them using your Flyway scripts? Background The best for tests is that you have one data set for one test and maybe even data sets for the database state assertions, but this would… Read More »How to migrate dbunit data sets?

Hibernate / JPA Lazy Loading Pitfalls

Hibernate provides different kinds of relationships between entities like OneToMany, ManyToOne, ManyToMany or OneToOne. In the early days of Hibernate the fething strategy of all relationships was “lazy”. This stayed true for a long time and changed when Hibernate started to support JPA, because the JPA specification defines different default fetching strategies. The default fetching strategy up to Hibernate version 4.3 is: By default, Hibernate uses lazy select fetching for collections and lazy proxy fetching for single-valued associations. These defaults make sense for most associations in the majority of applications. Hibernate 4.3 manual, 20.1.1. Working with lazy associations In contrast to this the JPA specification specifies different default fetching strategies per… Read More »Hibernate / JPA Lazy Loading Pitfalls

Migrate JUnit 4 to JUnit 5 using IntelliJ IDEA

IntelliJ IDEA provides a basic built-in support to migrate JUnit 4 to JUnit 5 tests. Even most of the steps to migrate JUnit 4 to JUnit 5 are already explained in the Jetbrains blog “Migrating from JUnit 4 to JUnit 5”, I would like to focus here on aspects that the current IDEA IntelliJ version, 2021.3.3 (Ultimate Edition) Build #IU-213.7172.25, build on March 15, 2022, does not cover. To enable the migration support you must enable the inspection in in Preferences | Editor | Inspections | JVM languages | JUnit 4 test can be JUnit 5. After you activated the inspection the migration is available at the class level and… Read More »Migrate JUnit 4 to JUnit 5 using IntelliJ IDEA

Typescript – cheat sheet

This cheat sheet contains typescript definitions that I sometimes use during development and that often can be easily forgotten. All examples are published on my codepen.io account so that you can directly edit and test them. They are also available in my codepen collection typescript cheat sheet. This cheat sheet is a work in progress and I will continue to add new sections. Wrapper function A wrapper function is a function that has the same signature as the target function it wraps. Wrapper functions are used applying aspect-oriented programming or a kind of implementation of the decorator pattern. See the Pen typescript cheat sheet – wrapper function by René Link… Read More »Typescript – cheat sheet

Lexical vs. dynamic scoping

In this blog I want to give you some examples about the difference between lexical and dynamic scoping. I will not dive into the details. You will find a lot of other resources about it. Here is a small list: Scope (computer science) Javascript — Lexical and Dynamic Scoping? What is lexical scope? The following JavaScript and Bash examples are almost equivalent in structure. Nevertheless they will lead to different results, because of the different scoping type these languages use. Lexical scoping – e.g. JavaScript In languages with lexical scope (also called static scope), name resolution depends on the location in the source code and the lexical context (also called static context), which is defined by… Read More »Lexical vs. dynamic scoping

Explicit access permission design with user roles

Most applications need access control and must therefore implement user permissions is some way. In a lot of the projects my colleagues asked me how I would implement user permissions. Since a lot of them found my thoughts an interessting way of implmenenting user permissions I want to share my thoughts here with you too. Maybe you can benefit from some or all of them or even create a completely new design. Annotation based permissions Usually you will implement permissions using annotations, but there are pitfalls and issues common to all annotation bases permissions. Annotation based user permissions code will often look like this: @Roles(“admin”) public class SomeClass { public… Read More »Explicit access permission design with user roles

How to test randomness?

In this blog I want to show you one way of how to test randomness. Randomness often appears when programming games. Let’s say you have a class that uses randomness, like a dice. When someone throws a dice it can be in one of six states 1,2,3,4,5 or 6. Thus you might implement the dice using a Java Random like the next example code shows. Can you test that class? A natural reflex is to say: “No, you can’t test it, because a test always makes an assumption about the result. Since the result is random you can never make an assumption that will always come true. Thus the test… Read More »How to test randomness?

Breaking static dependencies using Java 8 lambdas

Static dependencies are usually bad , because that dependencies are based on the class level and class objects can not be replaced at runtime in contrast to object instances. That’s why static dependencies are usually a pain if it comes to tests. When you want to write a unit test you usually want to mock the dependent objects, but you can’t do that if the dependent object is a class. Timing is for example hard to test, because it is based on the static call to System.currentTimeMillis(); and the result of currentTimeMillis changes all the time. Of course it does, because it’s the nature of time but that makes it also hard… Read More »Breaking static dependencies using Java 8 lambdas

Global java vm arguments

When you start a Java virtual machine you can specify various vm arguments. Some alter the memory management, some the garbage collection and some are system properties. But you can also specify global vm arguments that are picked up by every virtual machine that starts within an environment context. These global options are specified using the _JAVA_OPTIONS environment variable. _JAVA_OPTIONS=-Xmx1024m When you start a JVM while the _JAVA_OPTIONS environment variable is set you will see something like Picked up _JAVA_OPTIONS: -Xm1024m on the command line. The JVM tells you that it has found global java options and picked it up. Useful _JAVA_OPTIONS use cases Certificate management In a lot of… Read More »Global java vm arguments

One dot per line saves time

Today I want to introduce you to a simple rule that I apply when developing software. This rule often saves me a lot of time and it is simple to apply. I usually write code in Java and so the rule is made for Java programming in the first place, but it might also be adapted to other languages. I call that rule One dot per line The dot character in Java is primarly used for dereferencing. This also means that it can lead to NullPointerExceptions. The nature of NPEs is that they contain few context information. java.lang.NullPointerException at org.apache.commons.lang3.time.FastDateParser$TimeZoneStrategy.<init>(FastDateParser.java:869) at org.apache.commons.lang3.time.FastDateParser.getLocaleSpecificStrategy(FastDateParser.java:637) at org.apache.commons.lang3.time.FastDateParser.getStrategy(FastDateParser.java:606) at org.apache.commons.lang3.time.FastDateParser.access$100(FastDateParser.java:73) at org.apache.commons.lang3.time.FastDateParser$StrategyParser.letterPattern(FastDateParser.java:234) … This is primarily a… Read More »One dot per line saves time