How The Decorator Pattern Saved My Day
At work I am dealing with a huge Java code base, which was developed over the course of more than 15 years by many different developers. Not all things were done by the books but at the same time I...
View ArticleThe Decorator Pattern With Java 8
In a recent post I described how the decorator pattern saved my day. I gave a small code snippet which contained the simplest way to create decorators but promised that there would be a nicer way with...
View ArticleIntention Revealing Code With Java 8’s New Type Optional
Java 8 introduced a type Optional<T>, which can be used to handle potentially missing values. It does so by wrapping a reference (which might be null) and providing some nice methods to interact...
View ArticleThe Serialization Proxy Pattern
In my last post, I talked about serialization in general. This one is much more focused and presents a single detail: the Serialization Proxy Pattern. It is a good, often the best, way to deal with...
View ArticleDon’t Remove Listeners – Use ListenerHandles
Listening to an observable instance and reacting to its changes is fun. Doing what is necessary to interrupt or end this listening is way less fun. Let’s have a look at where the trouble comes from and...
View ArticleMultiple Return Statements
I once heard that in the past people strived for methods to have a single exit point. I understood this was an outdated approach and never considered it especially noteworthy. But lately I’ve come in...
View ArticleComment Your Fucking Code!
You’re the elite. You know Clean Code by heart, you dream of SOLID design, and you unit-test every line you write. Your code is so self-documenting you don’t even need to write comments! Then this rant...
View ArticleThoughts On Comments
Wow, telling people to comment their fucking code really hit a nerve. The reactions covered the whole spectrum from “just read Clean Code, dude” to “maybe some comments but just a little” to “OMG yes“....
View ArticleWhy Elvis Should Not Visit Java
I was recently involved in quite a long Twitter discussion regarding Java’s Optional, type systems that distinguish nullable and non-nullable types and the Elvis operator, which allows null-safe member...
View ArticleRepackaging Exceptions In Streams
Java 8 is a couple of years old but there are still use cases, not even edge cases, that the community did not yet develop a good arsenal of solutions for. How to handle checked exceptions in stream...
View Article
More Pages to Explore .....