Customizing IntelliJ for Emacs Compatibility

Atomic Object has a great tradition of making and customizing tools. It’s a habit I’ve gained and lost several times over my career — keeping tools sharp requires time and effort. Fortunately, one of the best things about becoming an Atom is that all of my colleagues care deeply about software, so it’s easy to find inspiration to start making tools again.

Read more on Customizing IntelliJ for Emacs Compatibility…

Beware the Elvis Operator in Groovy

While implementing a really simple caching mechanism in a Grails app, I came across what seemed like some odd behavior. I had an array of objects that would be built up within a function if not passed from the caller. To keep it as an optional argument, I had a default value of “null.”

def doStuff(arg1, arg2 = null) {
    arg2 ?: DomainClass.findAll(it.property == arg1)
 
    // Do stuff
}

This strategy was working most of the time, but there were still spurious database accesses whenever an empty array was being passed in. As it turns out, the spurious database accesses were occuring whenever the parent was passing an empty array for arg2. In Groovy, empty collections are falsy, as are empty strings and the number 0.

Read more on Beware the Elvis Operator in Groovy…