My colleague, Erik Timmers, and I often have discussions about programming and related technologies.
This blog post is the result of one of those discussions.
We discovered that the function Promise.race didn’t exactly do what we expected.
So we tested it, figured out how it worked, found out what we thought was wrong, and finally created a version of the Promise.race function that does what we expected.
After that we went a little bit further…and added some functionality to the function.
Please note that this code shouldn’t be used in production, or at the very least, it should be tested a bit more.
We did it “because we could”, but also because we wanted to understand the functionality.
If you would like to view, extend, learn from the actual code, the source code is also available on GitHub.
Continue reading →
Some time ago I went to a Meetup session “Death To Null” by Ties van de Ven from JDriven.
During the presentation it became clear that it wasn‘t so much about null checks and NullPointerExceptions but more about Immutability and how it can help keep your software free of bugs and NullPointerExceptions.
One of the statements that got me thinking was (something along the lines of): “Java chose the wrong default.
Instead of making everything explicitly final when we want an immutable variable, everything should be implicitly final unless the developer makes it explicitly mutable”.
Not knowing that much about the implementation of annotations I thought it would be fun to try to write an annotation which would do exactly that.
The first bump I encountered is that annotations cannot modify the programmers source code, or the classes generated from this source code; they can generate new sources or validate code.
This quickly turned my attention to project Lombok which does that already.
If you use project Lombok for the generation of getters and setters these never show up in your source code.
How can your IDE still hint at the existence of the getters and setters?
Continue reading →