We Java enterprise developers love abstractions in code. I suspect the typical software geek comes up with new abstractions more often than he changes his underwear. I admit to writing code with premature abstractions, such as using a strategy pattern where I end up never using a different strategy. We code defensively, afraid that lack of flexibility will hinder future changes. But beyond the code that we actually write, Java enterprise developers also love abstractions in third party libraries. We chase abstractions, in search of that fantasy land where if we adopt this or that framework we need not change our code to accommodate the hypothetical need to change the underlying implementation. The result is comic levels of abstractions upon abstractions.
This is a development-focused blog covering Java software development.
Tuesday, January 18, 2011
Wednesday, December 1, 2010
OOPs: mangling your database with objects
A developer once showed me a frightening sight: a page and a half of dense SQL, consisting mostly of join clauses. What was frightening was not so much the performance of this query -- it was a utility query, so the long query time was not important -- but the fact that he was actually proud of that query. How did a production DB schema get into such a state? The problem, in a word, was Hibernate. I'm a fan of Hibernate, so I'm not saying that there's something wrong about Hibernate. Rather, Hibernate lets you too easily do things that you should have second thoughts about. To borrow a metaphor, this tool comes with live chainsaws attached.
Monday, November 22, 2010
DVCS vs Subversion smackdown, round 3
That title is probably a little pretentious, since the topic of rival version control systems has probably gone a few zillion more rounds than that. The context here is that in a previous blog post I argued that the recent rise of DVCS (Git, Mercurial) is less due to their essential D (distributed) nature, but the accidental weaknesses of Subversion, the dominant centralized VCS. The weaknesses I mentioned are:
- Poor merging
- Lack of offline commits
Tuesday, November 16, 2010
I am a Torch bearer
I am a Torch bearer. More specifically, I am now a proud owner of a BlackBerry Torch 9800. This came as a surprise to me, actually, since I had no plans to buy one. The Torch is an AT&T phone: even after unlocking it, the Torch's 3G radio does not work on my T-Mobile network (wrong frequency). I own a Torch because my MissingLight app became a Regional Selection in RIM's 2010 BlackBerry Super Apps Developer Challenge, and the prize for that honor is a new Torch. I'm not complaining.
Friday, October 29, 2010
Beware the magic flush
It often surprises me what a good Java profiler can tell me about Hibernate performance issues. Recently I was studying a performance issue that seemed straightforward. There were lots of objects, lots of writes and lots of queries. Preliminary profiling showed one particular Hibernate query dominating the operation. That's not surprising, I thought: it's a frequently made query, and it's probably slow. I'll just find a way to speed it up, maybe with an index.
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:
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.
DVCS for all the wrong reasons
A lot of virtual ink has been expended arguing the superiority of the distributed version control systems (DVCS) like GIT or Mercurial over Subversion, the dominant open source "traditional" VCS. Representing a substantial paradigm switch, DVCS software is hip and adoption is growing. I will argue that DVCS adoption is driven not by the essential superiority of distributed VCS (the D in DVCS) but by the temporary, accidental weaknesses of Subversion.
Wednesday, August 25, 2010
Why Java needs Oracle
By filing a patent lawsuit against Google over its Java-like implementation, Oracle probably made itself the world's least liked software company. After all, Java itself is an open standard, open source platform that is ill-served by exclusive legal claims, right? Yet perversely, I think this patent lawsuit demonstrates why Java needs Oracle.
Tuesday, August 24, 2010
MissingLight 2.0 for BlackBerry
I released version 2.0 of my MissingLight BlackBerry app a few weeks ago. This blog entry provides the background for this release.
Sunday, August 15, 2010
Oracle vs Google: in search of a silver lining on Android
There is little to cheer about when the stewards of two of the most important application platforms in the industry, Oracle of Java and Google of Android, decide to fight it out in the courts. Oracle's lawsuit threatens both platforms: the publicity and "bad guy" image hurts Java, and the legal uncertainty hurts Android. It seems a lose-lose situation, doesn't it? Nevertheless, I still hope for a positive outcome for the Java world.
Monday, July 26, 2010
Why is it so hard to find a Java developer?
It's that time again. My employer needs another Java software engineer. We are looking for someone familiar with the usual enterprise Java stack: Spring, Hibernate, Tomcat. Pretty vanilla, right? So why is it so hard to find one? The problem is not with the frameworks: these are pretty widely used, and lots of people claim familiarity with them. My problem is the same one I've had for years: it's hard to find candidates who can clearly demonstrate their programming skills.
Tuesday, July 20, 2010
The rise of the cattle office
When I blogged about the office environment, I contrasted private offices with cubicles. Whatever their relative advantages, the latter suffered from noise, distraction and lack of privacy. Not long afterward, a colleague pointed me to Martin Fowler's article on team rooms that took these disadvantages and multiplied them:
Guess what this made me think of?
Moo.
(Photo credit)
Guess what this made me think of?
Moo.
(Photo credit)
Monday, July 19, 2010
Counting down my life
When I wrote TimeForTea for my BlackBerry, I had in mind a countdown timer to let me know when my tea is ready. As it turns out, a countdown timer has a lot more uses than that. I am indebted to my own customers for for their ideas of additional uses of TimeForTea. With room for 9 preset times, you can do a lot more than timing your tea. Looking over the reviews, I found a whole lot of other timing uses, such as:
- Washing cycle
- Dryer cycle (no more wrinkled clothes)
- Lunch break
- Pizza/Chinese takeout
- Kids' timeout
- Kids' video game time
Subscribe to:
Posts (Atom)