Top Posts of 2013: 10 Subtle Best Practices when Coding Java

 this is a list of 10 best practices that are more subtle than your average   josh bloch effective java   rule. while josh bloch’s list is very easy to learn and concerns everyday situations, this list here contains less common situations involving   api / spi     design that may have a big effect nontheless.   

i have encountered these things while writing and maintaining  jooq  , an  internal dsl  modelling sql in java. being an internal dsl, jooq challenges java compilers and generics to the max,  combining generics, varargs and overloading  in a way that josh bloch probably wouldn’t recommend for the “average api”.

10 More Common Mistakes Java Developers Make when Writing SQL

i was positively surprised to see how popular my recent listing about   10 common mistakes java developers make when writing sql   was, both  on my own blog  and  on my syndication partner dzone  . the popularity shows a couple of things:

anyway, the common mistakes i listed previously are far from complete, so i will treat you to a sequel of 10 subtly less common, yet equally interesting mistakes java developers make when writing sql.

jOOQ Internals: Pushing Up SQL Fragments

Over the past 13 years, jOOQ has accrued quite a few internal features, which you, the user, are not exposed to. One very interesting feature is the capability for any arbitrary jOOQ expression tree element to push a SQL fragment up to a higher level.

How does it work?

SQL DISTINCT Is Not a Function

A very common misconception I often encounter with SQL users is the idea that DISTINCT is something like a function, and that it can take parenthesised arguments. Just recently, I’ve seen this Stack Overflow question where the OP was looking for a way to express this in jOOQ:

SQL
 




x


1
SELECT DISTINCT (emp.id), emp.fname, emp.name
2
FROM employee emp;