I had quite a bit of trouble finding a good article about java streams vs for loops under this name so I guess I’ll have to write it myself.
In this article I would like to talk about the difference of using the Streaming API and for loops from the standpoint of long term maintainability of the code.
tl;dr:
To reduce maintenance costs of your projects, please do consider using the Stream API instead of for loops.
It might take some investment in learning to do so, but this investment will pay off in the long run, both for the project and for the engineers.
Nowadays we frequently see companies adopting the Elastic Stack to search, analyze and visualize application data in real time.
While the scope of application data ingested these days is broadening, it’s already quite common to monitor aggregated application logs in Kibana.
Because of this, I frequently find myself coming back to Kibana to slice and filter the logs to monitor how our application deployments progress through deployments.
In this blogpost, I’ll outline a small Vue.js web application I wrote to more easily access our application logs.
Continue reading →
Many companies that are undergoing a digital transformation are discovering that it is an endless endeavour.
Technological innovation allows a company to become more responsive to change in their business domain, but also makes it subjective to progress in the underlying technical implementation.
A lot can be said for the delivery pipeline optimizations that help deliver business value more efficiently, but how does your organisation keep up with technological innovation?
Continue reading →
How many lines of code do you actually need to implement external Role Based Access Control (RBAC) using OAuth, JWT with the new Spring Security features?
Lets find out!
Continue reading →
Nowadays we see more and more intelligence added to our applications. This can be in any form but mostly we see it in the form of predictions or some form of recognition.
This added value comes at a price and requires a new way of working within our established Software Engineering practice.
Continue reading →
If we want to include Asciidoc markup as source language and show the markup without transforming it we can use a listing or literal block. For example we are using Asciidoc markup to write a document about Asciidoctor and want to include some Asciidoc markup examples. If the markup contains sections like a listing or literal block and it is enclosed in a listing or literal block, the tranformation goes wrong. Because the beginning of the included listing or literal block is seen as the ending of the enclosing listing or literal block. Let’s see what goes wrong with an example where we have the following Asciidoc markup:
When we transform this to HTML we get the following output:
Continue reading →
This September, Jorrit van der Ven and I attended Heapcon in Belgrade. At this two-day conference,
we shared our experiences with developing in Kotlin at the Port of Rotterdam in our talk: 'Kotlin is for hipsters'.
Continue reading →
Normally when we run tests in our Gradle build, all our tests are executed and at the end we can see which tests are failing. But what if we want to let the build fail at the first failing test? Especially for a large test suite this can save a lot of time, because we don’t have to run all (failing) tests, we immediately get informed that at least one test is failing.
We can do this by passing the command-line option --fail-fast
when we run the test
task in Gradle. With this option Gradle will stop the build and report a failure at the first failing test. Instead of passing the command-line option --fail-fast
we can set the property failFast
of the test
task to true
. Using the property failFast
allows to still fail the build on the first failing test even if we for example run a build
task that depends on the test
task. The command-line option --fail-fast
only works if we run the test
task directly, not if it is part of the task graph for our build when we run another task.
Continue reading →
In Java we can use a Predicate
to test if something is true
or false
. This is especially useful when we use the filter
method of the Java Stream API. We can use lambda expressions to define our Predicate
or implement the Predicate
interface. If we want to combine different Predicate
objects we can use the or
, and
and negate
methods of the Predicate
interfaces. These are default methods of the interface and will return a new Predicate
.
Let’s start with an example where we have a list of String
values. We want to filter all values that start with Gr or with M. In our first implementation we use a lambda expression as Predicate
and implements both tests in this expression:
Continue reading →
Sometimes when we are developing we might to need to lookup the unicode value for a character. If we are using macOS we can use the Character Viewer to lookup the unicode. We can open the Character Viewer using the key combination ⌃+⌘+Space (Ctrl+Cmd+Space) or open the Edit menu in our application and select Emoji & Symbols. We can type the character we want to unicode value for in the Search box or look it up in the lists. When we select the character we can see at the right the Unicode for that character:
Continue reading →
When we write tests or specifications using Spock for our Spring Boot application, we might want to replace some Spring components with a stub or mock version. With the stub or mock version we can write expected outcomes and behaviour in our specifications. Since Spock 1.2 and the Spock Spring extension we can use the @SpringBean
annotation to replace a Spring component with a stub or mock version. (This is quite similar as the @MockBean
for Mockito mocks that is supported by Spring Boot). We only have to declare a variable in our specification of the type of the Spring component we want to replace. We directly use the Stub()
or Mock()
methods to create the stub or mock version when we define the variable. From now on we can describe expected output values or behaviour just like any Spock stub or mock implementation.
Continue reading →