Tuesday, September 23, 2008

Nowhere to hide (from) the Evil State

There has been some warnings sometime already from gurus, bloggers and article writers that we will have to get a lot more careful regarding writing code that is thread-safe. Most of the time programmers do it right, not necessarily because they have understood the whole problem, but because the default singleton behavior of the Spring framework forces them to.

On the other hand some old sins comes into the spotlight these days. Code that was written when developers only had single cpu-machines, and the multi-cpu machines really was not fast enough to uncover all potential problems.

Now developers has discovered what they can do with multi-cores and start writing new code utilizing them. The problem is that they reuse older code that was not developed with this in mind.
Most code handles data belonging to different users correctly. The problems often arises when code is executed multithreaded on behalf of a single user. Then there is nowhere to safely store state without lock-management anymore. Not even the database safe. It is no longer safe to assume that even a database only used by 1 system that rows "belonging" to a specific user can be updated without proper lock handling.

The old saying that "State is Evil" (wondering who said that?) has got a new renaissance. All objects belonging to the HttpSession must be managed properly for instance. I can see this can become challenging in a JSF application if you have the model is JSF managed beans. JSF does not let you (easily) replace the value of a managed bean. Guess there is some API's, but are they thread safe?
This means that if multiple threads is given access to controller- or model beans there must be proper locking on updates to the model.

Thursday, September 18, 2008

JavaZone 08 meltdown

I think this year's JavaZone was a bit varied considering quality and diversity of sessions, but all in all it was great. Is I posted yesterday some of them really inspired me. Todays session was not that "wooow", but I enjoyed some of them quite a bit. The BBS folks seem to really have gotten testing right in their Continuous Integration loop, and Unclebobs refresher on clean code was enjoyable.

I was a bit puzzled though by the first session today by Jason van Zyl where he showed a lot of bugs in his latest build of m2eclipse. The parts that did work I liked a lot, so I hope they get these things fixed. The parts about Nexus went better.

This year the JavaZone organizers introduced the use of Twitter and Hashtags for live feedback from the audience and speakers. It seemed like the number of twitters increased substantially from day 1 to day 2. Guess some got introduced to Twitter at Club Zone. Anyway it is cool that JavaZone introduced microblogging to the attendees, and I hope this will catch on in Norway and Java community especially.

Wednesday, September 17, 2008

Proprietary innovation - where has it gone?

Not that I miss it, but I still wonder after the first day of JavaZone 08. Most, if not all, sessions presenting something innovative was open source based projects or developers presenting new ideas.
I think this generally is a healthy development but is commercial Java Vendors now only implementing JSR's, and rely on the open source community to come up with real innovations. Well, partly, they are sponsoring and involving in open source projects, but my observations from the first day of JavaZone is still that the really interesting things going on is driven by independent developers. Adobe Flex seems to be the only exception, but that is a good one though as it is very innovative it is production ready and pretty useful too.

2 sessions really got me today: Richard Öbergs Qi4j and Anders Norås' presentation of Better Domain Driven Design
Both gave new impulses and ideas on how Domain Driven Design can be further improved. As always Ôberg delivers a bit of controversy and noncomprimising radically new thoughts. Qi4j offers a Composite Object framework utilizing Annotations and Dynamic proxies that enables composition of objects (not classes).
The framework is initself a very good idea, but unfortunalety Öberg could not recommend using it in conjunction with frameworks like Spring although some connectors exists.
Any framework must have (real good) capabilities of coexistence and beeing able to cooperate with other frameworks in all but very small systems.
I am also a little worried over deep stacks of dynamic proxies, which will have performance implications and possible obfuscating stacktraces (although Öberg said these would be removed from Exception stack traces), but these things tends to pop out anyway.

Anyway I will keep an eye on what's happening with Qi4j but I am afraid the gap from the currently widely used frameworks is too big.

Anders Norås presented a similar, but much simpler approach to the same problem domain. By using Guice and ordinary Java Generics he demonstrated much of the same capabilities of extracting non-domain-code into separate classes. I would give his approach a better chance of getting foothold, at least in the near future. On the other hand this approach did not provide as many goodies as Qi4j, e.g. the visualizer and elegant UnitOfWork management.

Both approaches provides innovating ideas to the Java community, they are typesafe and supports refactoring. If Arjen Poutsma, that also speaks at the confence, together with the other two could come up with intelligent ways of making these ideas and technologies available together they will provide even more value. It is seldom a choice not to include one or more of other widely used frameworks in projects today.

I had to go home, before the real fun starts, as I must be able to deliver the car for repair tomorrow at 06:30 before I return to day 2 of JavaZone 08. No Cafè Con Bar for me this year.