I just wanted to share a reminder not to treat Object.hashCode() as a key. This seems very basic, but I have seen experienced developers get tripped up over this method. A number of people seem to think that hashCode can be relied on to return unique integers for each object value, especially for strings. Oops.
This is a development-focused blog covering Java software development.
Wednesday, August 3, 2011
My latest BlackBerry app: TempoBeat
My latest BlackBerry app is out. Presenting: TempoBeat, an electronic metronome app. I paid quite a bit of attention to the user interface with this app, since I wanted something that works well with both a keyboard and a touchscreen. The controls can be manipulated by touch, but I also included a number of keyboard shortcuts for non-touch BlackBerry model. It has a bunch of features or characteristics typical of metronomes: tempo, beats per measure, volume control etc. This being a BlackBerry app, I added one more feature that truly belongs on a BlackBerry: you can use the iconic BlackBerry LED to blink the beats, in colors of your choice.
Tuesday, May 24, 2011
My blog will make you stupid
Apparently, my blog will make you stupid. It's no good fleeing to another blog, though: they all make you stupid. That is, if you agree with Nicholas Carr's book, "The Shallows: What the Internet is Doing to Our Brains". The thesis of the book is that our use of the Internet is changing our brains, affecting deep learning, long term memory and our ability to focus.
I first heard about this book at a No Fluff Just Stuff developer's conference, where more than one panelist at one session cited this book with respect. Clearly, I thought, this is not a book for Luddites if a bunch of technophiles are reading it. This book is not a reaction against modernity. In fact, I'd say that it is trying to preserve an aspect of human progress now threatened by the Internet. I'll get to that in a moment.
Thursday, April 14, 2011
NoSQL: triumph of application over data
NoSQL databases are the rage now, aren’t they? Not too long ago, NEJUG hosted a presentation by Tim Berglund called "NoSQL Smackdown." Before giving his tour of several NoSQL databases, Tim tried to give his definition of "NoSQL." After showing the difficulties of defining NoSQL as a series of negatives (no SQL, no relations, no transactions), he merely settled on a vague definition. Basically, he says, NoSQL is merely a set of different approaches in data models, querying and scaling that trade off things like performance and the 3 guarantees of the CAP Theorem.
In other words, there is no such thing as a canonical NoSQL database. Most emphasize key/value or document-oriented storage, but then you have something totally different like Neo4j, a graph database. NoSQL fans like to emphasize scalability, but some candidates don’t really scale. You can’t even say that NoSQL means no SQL, because you have something like GemFire, which does allow you to use SQL. Nevertheless, allow me to give you my own definition of NoSQL. Ready? Here goes:
NoSQL databases are databases for people who don't care about data.
Thursday, February 24, 2011
The pain of enterprise Java development
Tuesday, January 25, 2011
The trouble with being conventional
I've had a pretty rough time getting comfortable with Maven. This was a green field Java project: we were starting absolutely from scratch. There were no legacy build processes to support, so we were ready to follow Maven convention everywhere. Nevertheless, it has been a long, painful (one colleague said "character building") journey. Why did it have to be so hard?
Tuesday, January 18, 2011
Chasing abstractions
Wednesday, December 1, 2010
OOPs: mangling your database with objects
Monday, November 22, 2010
DVCS vs Subversion smackdown, round 3
- Poor merging
- Lack of offline commits
Tuesday, November 16, 2010
I am a Torch bearer
Friday, October 29, 2010
Beware the magic flush
As it turns out, it was a simple, quick query. There was little hope of speeding that query up much. But further profiling showed that very little time was spent actually doing the DB query. So what was Query.list() doing that was taking so long? It was the implicit flush. The Hibernate session keeps track of objects that you have loaded, looks for modified objects and writes those modified objects to the database when flushed. A final flush happens upon transaction commit. Additionally, Hibernate by default behavior flushes dirty objects to the database before making a query, to ensure that the query is made on data that reflects all updates made to that point. If you have lots of persistent objects loaded, each flush can be expensive because with each query:
- Hibernate has to check all persistent objects in the session for changes
- Hibernate will write any updated objects to the database. This can be wasteful:
- The updates may not be complete yet, so these intermediate writes are unnecessary
- Spreading the DB writes across reduces Hibernate's opportunities to batch SQL statements for performance compared to writing everything at the end of the transaction.
