Wednesday, November 28, 2007

Swingin' into '08

My first foray into the world of Java was back in 99-2000 when I was tasked with creating a rudimentary client/server app. The app was Swing based with simple UIs for the client and server parts of the app. I remember being struck at the time of how easy it was to create basic
UIs; much more so than the C++ Win 32 UIs I had written previously.

Since those days I've not really used Swing that much, my career since then has taken me more towards N-tier applications, generally with a web front end. In those eight years, I've used a number of web MVC frameworks and through the years have seen a great improvement in developer productivity and ease of development/integration as new frameworks have come along. In recent years, technologies such as AJAX have added a richer experience to the web client.

So, when I decided to take another look at my old friend Swing, I was excited to see what had happened in the intervening years. On initial inspection, not a whole lot seems to have changed. There have been good performance improvements, which is always worthwhile. One introduction in JSE6 (developed initially at SwingLabs) I've since used a lot is the SwingWorker class which helps offload long running tasks from the Event Dispatch Thread. There have also been tweaks to the look and feels (esp the Windows L&F).

However, I was surprised not to see more new features jumping out at me and begging to be tried. Perhaps there are more gems lurking which I haven't yet discovered, I hope so.

I think the main frustration in developing Swing apps is that although there is a wealth of supplied components; and it is relatively straightforward to create custom components; there's no centralised framework or patterns for laying out your application architecture.

There's also a large amount of boilerplate that has to be created for all apps. For example, how often have you written...

public void static main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MyAppFrame().setVisible(true);
}
};
}

... or something similar, just to make sure that the app is created on the EDT. I don't keep track (I'm not quite that geeky!) but it must be in the hundreds.

I'm therefore excited by JSR296 which should hopefully standardise the main structure of a Swing app and help development teams get up to speed more quickly as there should be a common understanding of how common functions are performed.

I'm also excited by JSR295 - Beans Binding which should simplify the process of binding the properties of GUI widgets to model properties removing yet more boilerplate for adding PropertyChangeListener instances.

Hopefully both of these will make it into JSE7 (Dolphin) but early versions are available on java.net.

I haven't had a chance to experiment with them yet but it's on the ToDo list.

One area I've been getting into since my return to client apps is animation and I've been experimenting with the Timing Framework developed by Chet Haase of Sun (available at http://timingframework.dev.java.net). It's fairly simple, only a handful of interfaces and classes. It's this simplicity that makes it a really nice framework to use. It's very easy to set up fairly sophisticated animations, quickly and easily with minimal coding required.

In the next few blogs I'll be running through some Timing Framework examples, showing how it can really simplify the creation of animations in Swing applications.

Monday, November 26, 2007

Time for a 2nd opinion

One of my passions and something I claim to know more than a little about is the Oracle database. I'm still learning and hopefully always will be.

It probably comes as no surprise that one of the sources from which I've learned a tremendous amount of information is Tom Kyte of Oracle (http://asktom.oracle.com). Now, Tom spends a large amount of time answering questions from us mere mortals on all topics Oracle.

The other day I was browsing the site and saw that the 'Ask a question' button was available. For those of you that read asktom regularly you'll know this is a fairly rare occurrance, as there's always a large number of questions awaiting Tom's attention.

So, I thought I'd ask a question regarding a semi-hypothetical situation that had cropped up with a legacy application. I'd been trying to figure out a way of reducing the serialisation time when trying to process records in a table (not a batch process - an online process where we need to process one at a time). I did my research and came across a few things I didn't know previously - including the undocumented SKIP LOCKED clause on SELECT FOR UPDATE and some alternative procedural approaches. So, I posed the question to Tom, was this a valid approach?

To answer, Tom pointed me in the direction of something I hadn't even considered but which was built right for the purpose, Oracle AQ. Fitted the problem domain exactly without requiring any of the workarounds I had thought of to cope with limitations of procedural approaches (all the what ifs...). Now with the original idea for the question being a legacy app, there'd need to be some adjustment to get AQ in there but a whole lot less work than trying to cope with the error scenarios and making sure we catch them all.

Moral of the story - It's reminded me it's always wise to get a second opinion on any design/idea you come up with for a particular situation. We techies sometimes have a tendency to overlook the obvious and reinvent the wheel when the answer is often right under our noses...

Thanks Tom!

Kevin '07 - Rudd sweeps to victory in Australian election

Well, it was a long shot, and 10 minutes is not a long time to attract your first comment... Oh well.

So, which option did I take??? I thought I'd start off with the extremely safe subject of politics. No danger there of enflaming any passions....

This was my first election in Australia having voted in the last two general elections in the UK and it was a very different experience.

For the uninitiated, Saturday saw the federal election in Australia with all seats in the House of Representatives up for grabs. In the blue corner, the government of the Liberal coalition led by John Howard who has been Prime Minister for the last 11 years. In the red corner, the Labor party, led by Kevin Rudd for less than a year. The final results in all seats are not yet counted but Labor have won a resounding victory, with Kevin Rudd set to take over as PM. It's also likely that John Howard will lose his Bennelong seat, the first sitting PM to lose their seat in 78 years.

So, what went wrong for the Liberals? Or was it a case of Labor winning rather than the government losing? Unfortunately I can't really comment as I don't know enough about the details but the overriding opinion seems to be that the government's controversial work choices policy was the main culprit.

What I noticed most was the amount of advertising on television and print, much more so than back home in the UK. Also, most of it tended to be negative advertising, bashing the opposition rather than promoting the policies of the advertising party. That was my outsider's perception anyway. Not that politics back home is any better; anyone's who's seen Prime Minister's questions on a Wednesday afternoon can testify to that.

Australia has a policy whereby everyone who is eligible to vote, must vote; under penalty of a fine. It could be said that Australia has a very active democracy and the people need no encouragement to vote. However it could also mean that there is a large pool of people who, would not necessarily vote without the threat of a fine. Whatever the case may be there was a small army of volunteers around in Sydney canvassing. It was refreshing in many ways, as someone ineligible to vote, being able to watch the spectacle knowing that I personally would bear no responsibility for the outcome.

On polling day, I was driving through my suburb and passed several polling stations. I was amazed at how many Labor supporters had gathered and were canvassing, right up to the end. I saw a few from other parties, mainly the Greens, but no conspicuous Liberal presence. Maybe that's the area I live in, but for a government many expected to lose, I was surprised not to see a larger Liberal presence.

11 years in government is a long time and there is always the argument for a change. So what happens now? Labor have pledged to abolish work choices, ratify Kyoto and start an education revolution. I'll await the outcomes and pass judgement in the future. One thing that worries me slightly is that I've never been a fan of unions and Labor is heavily union oriented. Hopefully abolition of work choices will not stifle innovation and job creation but we'll have to wait and see on that one.

Finally, since the election loss, the former Treasurer, Peter Costello and the deputy Liberal party leader have stood down from the front line of politics. Hopefully there will not be a vacuum in the Liberal coalition which prevents a strong opposition to the Rudd government as in any democracy, the opposition is cruicial in keeping the government in check.

The first of many inconsequential ramblings

Back in July 07, I decided to jump on the blogging bandwagon and registered for blogger...

...and that's where my blogging adventure has stalled to date.

So, on this glorious spring evening in Sydney, whilst waiting for a call to pick up my wife from the airport, I decided to tackle the task that has eluded my attention for some 5 months.

Why the delay? Is it a lack of ideas? Or possibly a lack of time? I'd like to think the latter but I'll let others be the judge of that.

So, in the interests of democracy - there's a nice segue into one of the potential topics - I'm going to give you, the reader the opportunity to decide on the subject of the next inconsequential rambling.

Here's the initial two options, as you can see, vastly different subjects:
  • Swing applications in the current world
  • Australia Election 2007
So, you have until I have finished making a cup of coffee, or grabbed a beer - haven't decided which yet - to comment on this post to let me know which you'd prefer.

Yes, I know this is a shameless attempt to drive traffic to this inaugural posting but there you have it.

Clock's ticking....