Tackling Accidental Complexity With Optional in Java

In a post in the past — "How do we make complex software less costly?" — I drew the distinction between essential and accidental complexity. The clue is in the name — you can't avoid what is essential. Build a good understanding of your core problem. Otherwise, you risk introducing more unnecessary complexity.

This time, let's talk about a specific functionality — Java Optional. I'll use an example project to show you how Java 8 Optional can impact the end complexity. And it can do so positively or negatively as Optional as a tool can simplify and complicate your code. In the long run, the outcome can greatly influence your project. Let's see how it works.

Painless WebSocket Tests with Spock Framework

Many Spring Boot web applications require you to go beyond the usual REST endpoints and start accepting WebSocket connections. Meanwhile, plain JUnit tests have fallen out of fashion, and suddenly everyone is talking about the potential of Spock.

All these changes sound thrilling, and you’d like to try the novel approach.

Modern Strategy Pattern in Functional Java

There's a way to think about design patterns that stuck with me. Like Venkat said at the beginning of his 2019 Devoxx talk, they are a lot like grandma's recipes. We all love when our grandmas cook for us. But try to ask for the recipes —the amount of flour or sugar to use is never precise. And when you prepare the food yourself, it comes out completely different.

In our biggest Java project at Evojam right now, we have tweaked the recipe for strategy pattern. We added our personal touch with a pinch of enums and functional syntactic sugar. As always, the easiest way to explain it is with an example. Let's jump right into it.