Skip to content

Blog

React Models

After a lot of years of application development I was just improving my frontend skills while learning react. Since my passion is architecture and therefore application structure, I thought about how to structure a react app. I thought about my frontend experiences in developing RCP applications build with Swing or Eclipse RCP (SWT). In those RCP environments one usually desings UI models that are stable abstraction of what one wants to view and then use UI components that operate on these models. Stable abstractions are usually a good practice that help you to stay flexible and with “flexible” I mean to easily change UI components and to easily test their… Read More »React Models

Fundamentals of React functional components you should know

In this blog I would like to demystify React’s functional components. I want to give you a deeper understanding of why React works as it does, so that you can focus on writing React applications instead of hunting bugs. Function components – the mental model gap In the “Main Concepts” section in the React docs they tell you what a function component is with a simple example. In the React docs, Main Concepts in the section Function and Class Components they say: This function is a valid React component because it accepts a single “props” (which stands for properties) object argument with data and returns a React element. We call such… Read More »Fundamentals of React functional components you should know

Port-forwarding with netsh on Windows

Sometimes you run a program on your Windows computer that binds it’s ports to only the localhost address (127.0.0.1). Usually you can configure the program to also bind to other interfaces. But sometimes you can’t reconfigure it or you don’t find the configuration options, because it’s poorly documented. In some situations there are also good security reasons why the program only binds to the localhost. So I also have to tell you: WARNING: Most times programs bind to 127.0.0.1 is because of security reasons. Thus you should take care when you want to make a port available to other computers in the network and you should not do it unless… Read More »Port-forwarding with netsh on Windows

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?

GDPR Cookie Consent with Real Cookie Banner