Before I move on with the actual article, I'd like to give credit to Daniel Dietrich, author of the awesome vavr library, who has had the idea before me: https://twitter.com/danieldietrich/status/699633269202149377 Contravariant Generic Bounds It all started with a tweet: https://twitter.com/lukaseder/status/699588908095508480 I wanted to do something like pattern-matching a common super type of a set of … Continue reading An Ingenious Workaround to Emulate an Application of Union Types in Java
Category: java
This category contains posts about things that are essentially Java-related
Dear API Designer. Are You Sure, You Want to Return a Primitive?
Some APIs are set in stone. For instance, the JDK's. Or public APIs, like the one between a database and a database client (e.g. JDBC). This makes designing such APIs rather difficult as a lot of thinking needs to be done prior to publishing an API. Which means that being defensive when designing the API … Continue reading Dear API Designer. Are You Sure, You Want to Return a Primitive?
Using Oracle AQ via Java 8 Streams
One of the most awesome features of the Oracle database is Oracle AQ: Oracle Database Advanced Queuing. The AQ API implements a full fledged, transactional messaging system directly in the database. In a classic architecture where the database is at the center of your system, with multiple applications (some of which written in Java, others … Continue reading Using Oracle AQ via Java 8 Streams
Use JUnit’s expected exceptions sparingly
Sometimes, when we get pull requests for jOOQ or our other libraries, people change the code in our unit tests to be more "idiomatic JUnit". In particular, this means that they tend to change this (admittedly not so pretty code): @Test public void testValueOfIntInvalid() { try { ubyte((UByte.MIN_VALUE) - 1); fail(); } catch (NumberFormatException e) … Continue reading Use JUnit’s expected exceptions sparingly
Reactive Database Access – Part 3 – Using jOOQ with Scala, Futures and Actors
Notice that the examples in this article may be outdated, as Typesafe's Activator works differently now. The blog post will not be maintained to provide up-to-date Activator examples. We're very happy to continue our a guest post series on the jOOQ blog by Manuel Bernhardt. In this blog series, Manuel will explain the motivation behind … Continue reading Reactive Database Access – Part 3 – Using jOOQ with Scala, Futures and Actors
If Java Were Designed Today: The Synchronizable Interface
Java has come a long way. A very long way. And it carries with it all the "junk" from early day design decisions. One thing that has been regretted time and again is the fact that every object (potentially) contains a monitor. This is hardly ever necessary and this flaw was corrected, finally, in Java … Continue reading If Java Were Designed Today: The Synchronizable Interface
A Curious Incidence of a jOOQ API Design Flaw
jOOQ is an internal domain-specific language (DSL), modelling the SQL language (external DSL) in Java (the host language). The main mechanism of the jOOQ API is described in this popular article: The Java Fluent API Designer Crash Course. Anyone can implement an internal DSL in Java (or in most other host languages) according to the … Continue reading A Curious Incidence of a jOOQ API Design Flaw
Please, Java. Do Finally Support Multiline String Literals
I understand the idea of Java-the-language being rather hard to maintain in a backwards-compatible way. I understand the idea of JDK API, such as the collections, to be rather tough not to break. Yes. I don't understand why Java still doesn't have multiline string literals. How often do you write JDBC code (or whatever other … Continue reading Please, Java. Do Finally Support Multiline String Literals
JEP 277 “Enhanced Deprecation” is Nice. But Here’s a Much Better Alternative
Maintaining APIs is hard. We're maintaining the jOOQ API which is extremely complex. But we are following relatively relaxed rules as far as semantic versioning is concerned. When you read comments by Brian Goetz and others about maintaining backwards-compatibility in the JDK, I can but show a lot of respect for their work. Obviously, we … Continue reading JEP 277 “Enhanced Deprecation” is Nice. But Here’s a Much Better Alternative
