Wednesday, November 5, 2008

Firefox is becoming my OS

There has been predictions for some time now, that the browser will become the OS meaning that importance, and even existence of, an OS will be less important.
E.g. here is a blog that discusses the issue.

I haven't come that far yet, as a developer I still need applications installed locally that depends on having a OS like Windows or Linux. But there has been some real changes in which applications I use, and how I access them.

First of all, blogging, social networking and getting informed is new activities that I now do regularly in the browser. My social networking activities has become quite varied and wide, so a lot of time is spent using the browser for these activities. All mail accounts is GMail, even for job purposes. My employer, Webstep is using Google Sites for exchanging all types of information, and it is accomplished completely using a browser. All this, and most of the time I do not even have to push the save-button. I wonder how many work hours has been lost because Microsoft products does not have auto save...

Firefox also has a lot of useful addons available. Ubiquity is definitely one of them, as I can do a lot of things with the content on the web pages I visit. I also use TwitterFox a lot, and GMail Notifier. The delicious plugin is used heavily and has solved my bookmark synchronization need once and for all!

Most of my tools I use at work is OS independent (Java), so it does not really matter if I use Windows, Linux or OSX. It's just a matter of personal- and project related preferences. The application that most often forcing me to use Windows nowadays is iTunes (no I will not provide a link!), and that is not freely. For my N95 I by music from 7Digital and Telenor Music Store which both works excellently in the browser across OSes. We have an iPod and to sync it, I find it easiest to just do what Mr Jobs tell me to do.

As a contradiction, I am now starting to use Maven more seriously on my daily work. Earlier the projects I have been working could not use Maven because of several reasons. With the m2Eclipse+Nexus plugin installed there will be less need to use the browser to find OSS components. Probably the largest step forward in improvement of my development tools in a long time. It really makes handling dependencies between components easier and a whole precise.

Tuesday, October 28, 2008

Finding Open Source code and components with Unit Tests

Yesterday I read an interesting article in IEEE Software about Code Conjurer Eclipse plugin and Merobase.

Merobase is a code search engine supporting some quite interesting features, among them querying by writing Unit tests. According to the IEEE Article, candidates matching the interface expected by the implementing class (under test) is actually tested with your test on the Merobase server.

Classes found that successfully fulfills the expectations in the test is shown in the search result.

Another interesting feature, is that results can be filtered in Code Conjurer showing only matches satisfying compliant licensing regimes that you specify.

So far I have only tested the web browser search interface, with some varying quality in the result. Anyhow this is a very exciting idea, and is probably something companies with large code bases would want to have in house.

This service has a real potential to reduce the "reinvent-the-wheel" problem, and improve collaboration inside and between organizations. In addition it can even get more people writing good unit tests.

Just one more thought: Why hasn't Google already done this with Google Code Search?

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.

Tuesday, May 20, 2008

com.sun.rowset.CachedRowSet pains

Yesterday I came across a nasty NullPointerException in the com.sun.rowset.CachedRowSetImpl class. The application has used rowset.jar for over a year now when using Spring JdbcTemplate, and it has been working as it should. Suddenly when deploying to WebSphere 6.1 we got

java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:404)
at java.util.Properties.load(Properties.java:332)
at java.util.PropertyResourceBundle.(PropertyResourceBundle.java:110)
at com.sun.rowset.JdbcRowSetResourceBundle.(Unknown Source)
at com.sun.rowset.JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(Unknown Source)
at com.sun.rowset.CachedRowSetImpl.(Unknown Source)
at org.springframework.jdbc.core.SqlRowSetResultSetExtractor.newCachedRowSet(SqlRowSetResultSetExtractor.java:83)
at org.springframework.jdbc.core.SqlRowSetResultSetExtractor.createSqlRowSet(SqlRowSetResultSetExtractor.java:65)
at org.springframework.jdbc.core.SqlRowSetResultSetExtractor.extractData(SqlRowSetResultSetExtractor.java:49)
at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:393)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:342)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:403)
at org.springframework.jdbc.core.JdbcTemplate.queryForRowSet(JdbcTemplate.java:446)


A year ago the project was using Sun JDK 1.4, which does not include the com.sun.rowset package. Sometime last year we upgraded to Sun JDK 1.5, and no one thought of removing the rowset.jar from the runtime classpath. Each developer runs the application on JBoss, and the rowset.jar has not caused any trouble here. The application is deployed as an exploded EAR in development.

When packaging for WebSphere the rowset.jar was put in /lib directory in the EAR, and the developers assumed that the IBM JDK 1.5 did not contain the com.sun.rowset package. Shmack, there the NullPointerException reared its ugly head.

Inside rowset.jar, there is a property file called com.sun.rowset.RowSetResourceBundle.properties that is loaded through this little nasty piece of code in com.sun.rowset.JdbcRowSetResourceBundle:

private JdbcRowSetResourceBundle()
throws IOException
{
Locale locale = Locale.getDefault();
String s = locale.getCountry();
if(!s.equals("") && !s.equals("US"))
propResBundle = new PropertyResourceBundle(Thread.currentThread().getContextClassLoader().getResourceAsStream("com/sun/rowset/RowSetResourceBundle_" + s + "." + "properties"));
else
propResBundle = new PropertyResourceBundle(Thread.currentThread().getContextClassLoader().getResourceAsStream("com/sun/rowset/RowSetResourceBundle.properties"));
}


I am living in Norway, so the code will actually be trying to load com.sun.rowset.RowSetResourceBundle_NO.properties which of course is not provided in the rowset.jar file. I really hope the developer at Sun who made this has a real good explanation for writing this.

Well, today we discovered that the IBM JDK 1.5 does provide the com.sun.rowset package, and the whole problem was resolved by removing the whole jar from the project. There is nothing like the good feeling when getting rid of som crappy code!

One of my peer project developers found this post that sat me off in the right direction. Especially the link to Ted Newards excellent ClassForName.pdf

BTW: http://del.icio.us/dagblakstad proved invaluable while resolving the problem and writing this post.

Wednesday, May 7, 2008

I'm now a Nokia Sportstracker Fan

The Nokia Sportstracker is one of the coolest thing around of you have Nokia GPS enabled phone.

Have a look at the combining with the Sports Tracker widget everyone can see that i'm not in very good shape.

In order to view the Nseries Widget you need JavaScript and Flash Player 9+ support