UUIDs make great identifiers – ones that are, for most practical purposes, unique, easy to generate, and hard to guess. The only problem is that they are long – 256 bits, but with a textual representation that’s 36 characters. So what if they were shorter?
Equality is context sensitive. It’s very rarely as cut-and-dried as people think it is.
As a simple example, consider two $5 notes. I think everyone can agree that these notes have the same value – they are both worth $5. But are they equal?
Building properly immutable objects in Java can be annoying, especially if they’ve got a bunch of properties – too many to put into a readable constructor.1
You can implement the Builder pattern, but a lot of the time that just feels like overkill. But you don’t want to put in a bunch of setter methods, because that’s just asking for trouble. So what do you do?
TL;DR version: Don’t implement
equals() on mutable objects.
This is a post I’ve been tossing around for a couple of years, ever since a lunchtime debate with a colleague. It’s a simple statement: You shouldn’t implement the
equals() method if your object isn’t immutable.1
I had all sorts of problems getting my head around how cache files work with Hadoop. Finally, I stumbled across the answer – when you add a cache file (see HadoopMain#48), it’s available to read as a local file inside the mapper (MyMapper#36).
When running in Elastic MapReduce, the file URI can be an S3 file, using either s3://bucket/path or s3n://bucket/path – this may or may not work in other Hadoop implementations, but the general approach would work fine.
See the gist at https://gist.github.com/twasink/8813628
For the last year or so, I’ve been using Atlassian’s Bamboo (in the OnDemand variant) for our team’s build server. And, mostly, it’s an awesome tool. Some parts, however, are a little rough around the edges. Building dependent projects is one of them.
We’ve been getting more interested in using RESTful web services and AJAX based applications recently. One of the tools we’ve been using with that is Jersey – the JAX-RS (JSR-331) reference implementation. I’ve been using it in anger for about a month now, and thought I’d write up some thoughts I had about it.
Continue reading “Jersey – a review”
Tony Obermeit posted a question to the AJUG-QLD mailing list asking for help with a problem reading XML snippets. So, I thought I’d help him out, and this is the answer I gave.
*Update*: As pointed out by Pepijn Schmitz, Sun already provided the same solution:
*Another update*: I raised an RFE with Sun for the vararg support Vote early, vote often!
Des Traynor did a little post about how languages are not all the same, and Jeff Atwood jumped in with a C# version. Java came out looking really bad at 15 lines for a simple program, but frankly, the reason isn’t because of Java; it’s because of the coding styles used.