Friday, December 15, 2006

Why would you go for Wicket too?

To answer that question Ryan Crumley investigated a couple of web frameworks for long term web development. He choose Wicket for a number of teams, even though there was lots of knowledge for older things like JSP. You can read his report to the wicket user list on nabble.

Thursday, November 30, 2006

Wicket most active Java Web framework forum


As you can see on this Nabble page, Wicket has the most active forum of all registered Java Web Frameworks.

Ruby on Rails and Django are the hot things in Ruby and Phyton land. So may we conclude Wicket is the hot thing in Java land?

Typo of the week

Found on Tor Nobye's blog:
Hi Matt, I asked Roman Strobl the "Go to File" or "Open File" dialogs (equivalent to Idea's Ctrl+Shit+N). He assured me that this is planned to Netbeans 6.0.

Wednesday, November 22, 2006

SOA and Application/Integration databases

Hmm, I was going to write about a new insight. SOA has been reported to give huge cost savings. I figured that must have been because they used an application database and prevented the complexity of an integration database.

But of course, our hero Martin Fowler has already thought of that. Its right there in the second link.

Lessons from giving a workshop Introduction Spring

Yesterday I lectured a small group of students at the Hogeschool of Amsterdam to introduce them into the wonders of the Spring framework. To my surprise it was quite hard to convert the abstract ideas from Spring in to something lively and concrete.

Luckily one of the students suggested to explain the workings of dependency injection by working through the 'hello world' application from the book 'Spring in Action'. This I did using Eclipse with all keyboard shortcuts I known.
But even then, I am not sure I could really explain why Spring is useful. Simple examples never do just to Spring's power as they are more easily written directly in Java.

I am afraid that seeing why you need Spring only comes when you are building a real application.

Sunday, November 19, 2006

Charles -JRuby- Nutter visits The Netherlands

December 19, JRuby author Charles Nutter will talk about his work on JRuby in Rotterdam, The Netherlands. The meeting is organized by my colleagues at Finalist. The presentation is free and open for everybody. If you're interested (and of course you are), send an e-mail to seminar@finalist.com.

More information (Dutch)

Note: There is a rumor that Thomas Enebo, another JRuby author will also be there.

My first (bad) Ubuntu experience, long live SuSE

SuSE 9.1 is no longer supported so it was time to update my home firewall. SuSE has been my choice since its 6.0 version many year ago. But now that there are so many hallelujah stories on Ubuntu, I thought lets give it a try. The installation went well but as soon as it was prime time the computer simply rebooted right after grub had loaded the kernel and the initial ramdisk. No error message or anything else to shed some light on the matter, just a friendly beep and the process started all over. I tried the 6.06 and the 6.10 versions, with the same results. The weird thing is, the hardware is not even that old (its an AMD-K6 at 400MHz) and has more than enough memory (almost 400Mb) and harddisk space (6 and 30 Gb).

After that I went through hell to get the firewall running again. My steps included:
- installing an ancient SuSE 7.0 from CD
- figuring out how to get that SuSE 10.0 installation DVD copy I accidentally still had on my MP3 player to the firewall's second harddisk
- trying to update SuSE 7.0 to 10.0 (it refused)
- figuring out how to make a SuSE 10 installation boot CD (see previous post)
- installing SuSE 10.0 from harddisk

Weirdly enough the hardest step was to copy the SuSE 10.0 installation files to the firewall's harddisk. First I tried WarFTP to serve it from my Windows machine. However, I kept getting access denied errors (configuring WarFTP is a science), and the ftp program is not really suitable for recursive retrieval. I finally succeeded by using the smbclient program.

Perhaps I'll try Ubuntu again when SuSE 10.0 is no longer supported. Unfortunately this is already next summer, sigh.

Update 2006-11-22: In my hurry to write this article I made a small mistake: my previous SuSE version was 9.2 and its support has been discontinued as of today. SuSE 10.0 is good to go until October 2007. See also SuSE lifetimes.

Creating a SuSE installation boot CD

Suppose you have a copy of the SuSE 10.0 DVD, but you don't actually have a DVD player on your target computer. Here is a way to work around that:

Requisites:
- target computer must have a CD player and a BIOS that supports booting from CD
- target computer must have some means to get to the installation files, preferably these are put on a not-in-the-way partition on the target computer (for example on the second harddisk)
- a (unix) computer with package mkisofs installed
- some way to burn an iso image to CD

Steps:
- cd to installfolder/boot, where installfolder is the root of the installation source
- execute

mkisofs -R -b loader/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -o suse10-installation.iso loader

- burn the result to a CD
- make sure the target computer has a means to get to the installation source
- let the target computer boot from the CD

When you are in the installation program you can do a ' back' to get in the installation program's menu. From there you can configure an alternate installation source.

Note that if you choose to install from a harddisk partition you should NOT format it, and you should NOT try to mount that partition during the installation. If you want you can mount the partition after the installation.

Sunday, October 29, 2006

JRuby on Rails status

JRuby 0.9.1 is out for a week. This is the first version in which JRuby really starts to perform and behave properly. Though Ruby on Rails has been reported to work on JRuby for a longer time, this was not repeated by many people; too many loopholes to jump through. However, with the advent of version 0.9.1 there are suddenly many people on the mailing list that are trying and achieving exactly this.

Another promising release was done yesterday in Japan: rails-asyncweb 0.1, a very fast web server for JRuby on Rails. TAKAI, Naoto's asyncweb uses AsyncWeb, a web server that prevents the synchronization pitfall that the Java Servlet API brings. AsyncWeb scales a lot better under load then traditional Java web servers. And the performance rocks! It is about 10 times faster then Webbrick under loads to 10 concurrent users. It will be very interesting to see what happens under much much larger loads. I am also curious how this will compare to Mongrel, Zed Shaw's successor for Webbrick in the C-Ruby world. Another interesting question is whether this will end Mongrel's Java port.

Another web framework that works under JRuby is Camping. Camping is smaller then 4K, but quite powerful. It is a creation of the well known Ruby virtuoso why the lucky stiff. If you want to get a feel for what Ruby can do but don't want to learn Ruby on Rails (which I found quite a large task) I recommend you try out Camping. Ola Bini has a nice tutorial on getting you started. (Note: you should not use Camping version 1.5 because JRuby does not support continuations.) Another very good Camping tutorial (Dutch) was written by Remco van 't Veer.

Update 2006-10-30: added Remco's tutorial.

Friday, October 20, 2006

Wicket autocompletion improvements

Here is how I extended Wicket's (version 1.2.2) autocompletion with 2 new features:
- immediatate open of the drop-down as soon as the text field gets focus
- define the width of the drop-down independent of the text field

As the JavaScript is well hidden within Wicket and is not easy to extend, I tried another approach that worked well. I created the package wicket.extensions.ajax.markup.html.autocomplete and placed my own edit of wicket-autocomplete.js. Because the package is compiled into my WAR I am sure it is the first on the classpath.

First of all, in the initialize function I added the following fragment:

 if (obj.className.indexOf('immediateopen') != -1) {
     obj.onfocus=function(event){
         updateChoices();
         return null;
     }
 }
Secondly I changed function showAutoComplete to the following:
 function showAutoComplete(){
     var position=getPosition(wicketGet(elementId));
     var menu=getAutocompleteMenu();
     var input=wicketGet(elementId);
     var rem = input.className.match(/\bmenuwidth(\d+)\b/);
     var menuwidth = (rem == null) ? input.offsetWidth : rem[1];
     menu.show();
     menu.style.left=position[0]+'px'
     menu.style.top=(input.offsetHeight+position[1])+'px';
     menu.style.width=menuwidth+'px';
     visible=1;
     hideShowCovered();
 }
That's it. Its fully backward compatible, except that if you use the classes immediateopen or menuwidthXXX you'll get the new behavior. If you are lazy, you can download the complete file.

Example:

  <input class="inputcode immediateopen menuwidth300" type="text" />

Tuesday, October 10, 2006

If programming was as risky as parachute jumping...

Last Friday my company organized a parachute jump. Unfortunately the clouds were, typically for the season, too low and the wind was too hard. But I learned some interesting things anyway as the morning was spend on a crash course testing by Kees Blokland from PolTeq.

One of the major things for testing is risk analysis; the amount of time spend on testing an aspect of the system is proportional to the risk of that aspect (where risk is chance of failure times impact). For fun we made a risk analysis of parachute tandem jumping. To make it more real the instructor and owner of the jumping company also joined the discussion. He told us what he does to keep jumping safe and the risk low. He named two aspects 1) attitude, and 2) an open culture. An open culture is important because incidents must always be reported so that they can be analyzed and prevented in the future.

The attitude aspect coincided well with a discussion we had earlier about the tendency to not test well. Sometimes the client thinks it is not necessary, sometimes developers don't know how to test properly, and sometimes they don't want to.
I asked what the instructor did to maintain a good attitude so that we might apply his lessons in the world of software. Here was his answer:
1. parachute jumping in itself already attracts the right type of people,
2. everybody understands that safety and risk control is paramount,
3. maintain maximum openness about incidents,
4. make an example, even a bruised toe is reported to the authorities, and
5. take disciplinary measures only when there is an attitude problem. These measures are usually drastic, for example a withdrawal of the jumping permit.

So what can we learn from this? Here are my ideas derived from each answer:
1. Attract people with the right mind set. Look out for people that are both result and quality driven.
2. Train you project managers, and require them to organize risk assessments. In software not everything is deadly dangerous and not everythings needs to be tested.
3. Use bug metrics. I am not so sure about this one. But you should at least use automated testing.
4. Even a technical team leader can make bugs. Be sure that everybody knows that.
5. Don't blame people when they do something wrong. But give the pink slip when they refuse to improve.

Even when you will apply these lessons, you will have to realize that only when programming will be as risky as parachute jumping, programs will become bug free.

We made the jump 2 day later. It was great and there were no bugs.

Monday, October 9, 2006

What makes a programmer?

The answer to this rather philosophical question came up yesterday on the way home from my company's parachute jump event (more on this in a later post). My superior explained how he used to program in the past: "Try something, and if it works add more. Things that are used more then once are moved into methods." This approach will work for small projects, but will create a big mess over time. It will definitely create a mess immediately for larger projects. We are lucky that he is a good manager, but also lucky that he does not program for our customers.

So how does a good programmer work? In my opinion the sole work of a programmer is to map abstractions onto other abstractions, and to add new abstractions when this is not possible.

Lets give a simple example. XML documents are a well known abstraction for a hierarchical structure of labeled values. Files are a well known abstraction for a named sequence of bytes. To persist an XML document one writes code that maps the first abstraction to the second. How to do this is well described in the XML standard, but is definitely not the only way. I have written more performant mappings for specific cases.
A more complex example: to understand a voice command, one of the mappings might be from a sound sample to vowels and consonants.
Other types of abstractions are written in functional designs, test documents, etc.

So what makes an excellent programmer? An excellent programmer:
- Works with well known abstractions. There is not much to know about XML documents and Files. This makes them easy to understand and versatile. RDMSs provide an abstraction for storing tabular data. They are more complex, but well know.

- Will create small and consistent new abstractions.
An excellent programmer will create small levels of abstractions in his system with consistent terminology. For example, while processing sound samples it may be wise to create an intermediate level of abstraction that facilitates working with different sample rates and sample sizes. Consistency can be reached naming things carefully. Simply using the same names for the same things is a good step.

- Can work with many levels of abstraction at the same time.
At times it will be necessary to understand how the different abstraction mappings interact. For example, while persisting a phone book in an XML file, you need to know what each mapping does with character encoding.

So how do you do all this? Unfortunately I have no simple receipt as my manager has. I am afraid, excellent programming is still a craft.

Wednesday, October 4, 2006

Top3 reasons for using NetBeans

Here is my top 3 reasons for using NetBeans:

3. You are masochistic, and like to change IDEs once every while
2. JPA support is apparently quite good
1. You are going to work for Sun

Tuesday, October 3, 2006

Wicket getting even more serious

I just saw on the Wicket e-mail list that there is now a company that provides commercial Wicket support. Their name is, guess what: Wicket Support.

Their initial coverage is basically Europe and United States. But they are interested in extending it if the opportunity arrives.

Monday, October 2, 2006

Wicket getting serious, Pro Wicket - Book Review

One of the interesting new web frameworks that saw the light recently is Wicket. Wicket is quite radical in that it relies solely on Java programming and does away with configuration and JSP/PHP/Rhtml type html generation. Although not unique in this approach (e.g. Barracuda, Tapestry) many web-developers will have a hard time getting up to full speed quickly. Luckily this has changed with the publication of the first Wicket book: Pro Wicket by Karthik Gurumurhty.

The book 'Pro Wicket' guides you through the development of a simple and sometimes not so simple web application. Page by page the application is extended and shows more and more Wicket features. Sometimes a 'mistake' is made. That mistake is then later 'corrected'. Unfortunately this makes the book less suitable as a reference book as you always have to flip through the chapter to see if you have the complete example.

The contents of the book varies nicely. The basics and way of thinking in Wicket are explained with lots of examples. Also the internationalization features are thoroughly explained (although I find it disturbing that the example mixes up languages and countries). There are well set up explanations and examples on how to integrate popular technologies like Spring and Hibernate. The AJAX examples cover the basics (which are quite good in Wicket) but a lot is left to be discovered. Testing is even less well covered, but at least here some good pointers are given to the manuals. A nice touch is to take a brief preview of Wicket 2.0.

The book is completely written in speaking language. The following sentence is typical: "As you might have guessed by now, this method returns false by default.". For some people, like me, this is a turn down, but most are probably okay. What is worse is that on every page you'll find pronouns (like 'it' and 'that') for which it is quite unclear what is referenced.

The Achilles' heel of the book is in the end of chapter 2 where there is a totally incomprehensible explanation on how to use repeating page elements in Wicket. I find it a shame that such an important subject is tucked away at the end of a chapter on a different subject (validation), and that the reader is suddenly confronted with a page full of abstract terms and such a small example.

I had a hard time reviewing this book. At many points I thought that the book was not finished enough to be published. Of course this was okay as I was reading the beta, but when the final book came out I noticed that only the code examples had been thoroughly updated. I am afraid that either the publisher pushed this one too hard, or the author just was out of time.

Conclusions
Despite some of the remarks above I am going to recommend this book anyway. First of all because it is the only Wicket book on the market, secondly because it does teach you Wicket. And that is a Good Thing.

Thanks to Apress for providing the book for this review.

Update 2006-10-05: Added link to Karthik Gurumurhty's blog, removed spelling mistake, deleted all comments related to the spelling mistake.

Friday, September 29, 2006

Back to Radiant

In one of my first posts I talked about Radiant. Having tons of other stuff to do, it dropped below my horizon. Because I am still on the mailing list, I saw a presentation passing by from Nathan Wright. The presentation is a beauty for first time Radiant users. I can highly recommend it if you like Ruby and are searching for something to build a simple site.

Because I can't find a download, I've put it on my home server for now. So here it is:

Radius, Content Management Simplified (5.6Mb)
Denver Derailed meeting September 27, 2006
Covers Radiant version 0.5.2 By Nathan Wright

Update 2006-10-02: Thanks to Luis Lavena for providing a more solid server.

Update 2006-10-04: The link above is now pointing to Nathan's own blog.

Update 2007-03-06: All previous links are now dead. I placed the copy on my home server back.

Thursday, September 28, 2006

Wicket for BSCs

Since I am finally getting to do a Wicket project (more then a year after I first learned about it), I subscribed again to the Wicket user mailing list. Initiated by an e-mail from Erik Brakkee, I started a thread to find out how to convince Big Slow Companies (BSC) to use Wicket and finally leave Struts in peaceful history.

There was only one criterion for the items in the list: they must be one-liners that are irrefutable so that there is no place for any FUD.

Together we came to the following points:

- Wicket enables scalable development. It is easy to split the work over many developers, it is even easy to split the work for HTML people and Java people.

- Wicket provides a natural programming paradigm familiar to Java and other OO developers. There is no need to learn new languages, Java and HTML are sufficient.

- The Wicket user e-mail list provides excellent support.

- Wicket has excellent feedback messages in case something goes wrong. Furthermore, Wicket is robust and shows no weird or unexpected behavior.

- Wicket provides excellent clustering support. When required, it is possible to optimize session usage.

Although there was some strong support for including reusability and maintainability I did not do so. I have yet to find BSCs that deeply care about these issues.

Thanks go to Eelco Hillenius for his infinite ability to promote Wicket. Thanks to Che Schneider for coming up with the TLA BSC.

Friday, September 22, 2006

Java voor Excel Quiz

Here are some projects:
- JExcel
- Java Excel API (aka JExcelApi)
- JXL
- POI

Which one does not belong in the list?

I'll post the answer in a few days with some more information on each project.

Update 2006-09-26

JExcel is a commercial library for for integrating Microsoft Excel into Swing applications. It will actually show an Excel sheet in your Java app (you do need Excel installed). From your Java code you can change the worksheets. Sounds neat, but I wonder who would want to use this. One thing I found is that the API seems to be a evolution of the following project: Java Excel API.

Java Excel API is an open source java library with which you can read, write, and modify Excel spreadsheets. I am currently using this one as it had some better blogs then POI. Although it does it works, I am not completely happy with it. The API is not consistent (for example: you can make something bold, but there is no obvious way to check whether a format is made bold) and the package structure and class names are kind of weird.

JXL is an umbrella for a couple of small open source java library with which you can build distributed Java programs with distributed class loading. I did not look much further into this. It seems that it tries to do JavaSpaces like things.

POI is again an open source project with which you can read, write and modify OLE2 documents including Excel and Word files. I have never used this, so I can not compare it to JExcelApi.

So the answer is: JXL.

Thursday, September 7, 2006

More portlet woes

I've got my portlet running for some time (see previous post). I even have a weird hack to enable file downloads. The Spring portlet MVC framework helped me a lot to structure the portlet really nice.
But now a colleague has started to write portlets as well. And guess what, he is as frustrated as I was. To make things worse, even with my previous Pluto experiences, there is nothing I can do for him! It is all so complicated with nondescript exceptions and configurations all over the place.

These 2 reasons (bad exceptions and configuration) are exactly the thing why Spring is such a joy to work with compared to using an old style EJB setup. And, you can even do better. The web framework Wicket gives you no configuration at all! And it still gets better: no more JSPs! Wicket to conquer the world!

Thursday, August 31, 2006

Walking the Java Road

I am walking the Java road. This week I told a junior programmer that learning Java is not something you start and then complete. Its a road; you learn as long as you are doing it. I am on the Java Road for 5 years now and I am still learning every week, almost every day even.

So what about this Ruby Road over there? It is a lot smaller road, but it appears that only fast vehicles are allowed. You really need to steer well, no mediocre developers here, they've crashed way behind you. And when you finally get it, boy, you get to go fast.

The major problem with walking on 2 roads is that you only have so much time in your life. I need time for the ones I love and then I need some sleep now and then. I would not mind switching, but then there should be enough work. Unfortunately, all the interesting stuff is still in Java. So for now its Java for me. But I'll keep looking...

Thursday, August 24, 2006

Profict Java Summer Camp - AJAX

I am just back from Profict's AJAX day, a very nice way of promoting one's company among developers. There were 2 speakers: Greg Murray, the AJAX architect from Sun and Bram Smeets, the DWR expert from Interface 21. In between there was a small product presentation from BackBase.

4 hours for Greg Murray
Four hours were filled by a jetlaged Greg. It seems that because he got so much time he could not chose what to tell from the many presentations he brought with him. It was a shame everything was so jumbled up because there were some really nice things in there. Without going into too much detail, here are some of the things he presented.

jMaki
Greg is the main author for jMaki. jMaki is a small toolkit that allows you to wrap other Javascript toolkits (among others Dojo and Zimbra). jMaki comes standard with some nice widgets. Besides the usual datepickers and autocomplete stuff, there were some very nifty widgets that allow you write Mashups with Flickr, Yahoo Geocoder and Google Maps. A Mashup is a mashed combination of several web applications. One of his examples was a reworked Petstore where each pet was indicated on a map. jMaki is available for JSP and JSF environments. But given the raw components (simply a html, css and js file) you can probably include this stuff in any other framework easily.

jMaki also has some other basic stuff. For example an eventing mechanism (modeled after Dojo) and XmlHttpProxy. XmlHttpProxy is an XmlHttpRequest like feature that will allow you to call services in any domain by proxying the call on a server. This circumvents the security mechanism of Javascript in which you can only do HTTP requests to the domain from which the page was served.

AJAX, Back button and Anchor links
The trick of the day was the use of anchor links (the part after the #). When the user triggers an AJAX action (for example loading a different product), the URL of the currently loaded document is changed, but only in the anchor part. Since only the anchor changes, the browser will not reload the current page, but will add an entry to the page history. This means that suddenly the AJAX enabled page has a bookmarkable URL. In addition, much better back button support becomes possible.

Bram Smeets on DWR
The 1 and half hour presentation from Bram was a very nicely done introduction to DWR. In contrast to many other Javascript toolkits, DWR only provides communication between JavaScript and Java. However, as this presentation showed, DWR does so very well. In short, the idea behind DWR is that you can call a Java method directly from Javascript, and then can use the returned objects as if they are plain Javascript objects. If so desired, some utility Javascript functions can easily convert these objects to HTML and put them into the current page.

First an example was presented for DWR with plain Java and XML configuration. The few lines of Java and Javascript code on the slides showed that DWR is really a convenient thing to use. One of the killer features is a debug view of all exposed classes and methods. After a pitch style introduction of Spring, Bram then showed how to configure DWR from Spring. Though the integration is indeed nice, it gives you no advantages when you are not using the Spring bean container for some other reason (which of course there are plenty).

Reverse AJAX
The audience really heated up with the topic of Reverse AJAX (a.k.a. Comet, Long poll and for some even as Pushlets). This experimental DWR feature allows you to execute Javascript from Java. A very very neat example showed a method call on a Java-Scriptaculous 'impersonator' on the server side, with as result that the Scriptaculous effect is applied in the browser. Unfortunately Reverse AJAX is still at an experimental stage. As Bram told me later, this is mainly because it has not been tested properly in many circumstances. In addition, you must be very aware of the load this brings to your server.

Barbecue
The day ended with a nice barbecue in the beautiful garden of Profict's castle.

Monday, August 7, 2006

Swing Date Pickers

Back in April I looked around for a good open source Swing date picker for a big Swing project. I found 6 and I actually tried them all. But in the end we simply stayed with JSpinner components.

These were the must-have requirements:
1. support for typing dates directly (this is, without opening a pop-up)
2. ability to limit the selectable dates with a lower and/or upper boundary
3. good event mechanism

And some nice-to have requirements:
4. visual mouse selection
5. support for multiple date formats
6. look good
7. further limitation of selectable days, for example no weekend days

These were the date pickers I tried:
- JCommon
- MDateSelector
- SwingX's date picker
- UICollection's date picker
- JCalendar
- And there was a sixth, but I can not find it back anymore.

None of these met the must-haves. In particular requirement #1, keyboard support, is only present in the the SwingX component. In contrast good old JSpinner supports #1-#3 splendidly, but fails miserably on #4-#7.

However, my search did seem to have some result.

It started with comment on an introduction on the SwingX JXDatePicker by R.J. Lorimer on JavaLobby. This guy writes good stuff. Then I thought, why not ask on the SwingX forum directly. So I wrote this message in search of more features. The message was followed by a lively discussion in search of requirements.

It seems that the SwingX guys picked it up and are now working on the final killer Swing date picker component!

Sunday, August 6, 2006

The Pragmatic Programmer - Book review

A colleague from the company that currently hires me, proudly told that they have a copy of the The Pragmatic Programmer for every 3 employees. Having just finished the Spring MVC book, I thought lets see what this is about. So I read the book and here I will convince you to read it as well.

After only a few chapters 2 strong thoughts came up and remained there for most of the rest:
1. What a dull book, I am already doing this stuff. But more importantly:
2. This is Good Stuff, I wish more people would read this book.

Though the book is old (2000) it is still very relevant. It contains a large set of well described programming practices and attitudes. You can read the entire book in any order. From experience I can say that what this book says, will really help you build better code more quickly.

One point I loved, is when the authors write off the construction metaphor (which is so previous century) in favor of the gardening metaphor. 'Gardening' is much better for explaining to business people why you sometimes need to spend time with no visible improvements.

I wondered why I had never seen iContract before, which is I think a hidden gem of the book. Apparently it is only recently resurrected.

As a totally unrelated bonus, I finally understand the use of Linda like technologies (Rinda/JavaSpaces).

Some minor points:
- I only noticed one trend away from this book: things like Active Record makes the section "Code generators" a bit redundant. Of course it can still be useful. Just watch out for software in which you don't need it.
- Exercise 23 states that it is a good idea to set java references to null after you are finished with the object. I disagree. You can consider doing this when you are writing code for a particular (old) JVM version that you happen to know intimately. And even then I would say that your methods are too long.

Anyways, the book does justice to its title; all tips are practical and executable. The more people will use ideas from this book, the less bad software I will have to work with. So here is my request to all colleague programmers: please go and read this book!

Author blogs: Andrew Hunt and David Thomas

Sunday, July 23, 2006

Java 7 improvements

Since now seems the time to request new Java 7 improvements (see for example Bag O' Tricks) here are my requests:
  • Type aliases I really hate having to type code like
    private Map<String, List<StringFormatter<DomainThing>>> map = new HashMap<String, List<StringFormatter<DomainThing>>>();
    It is so non-DRY that my fingers ache every time I see code like this.

    Here is an alternative:

    private class DomainFormatterList :     List<StringFormatter<DomainThing>>;
    private Map<String, DomainFormatterList> map =
        new HashMap<String, DomainFormatterList>();
    Still some repetition, but a lot better already. Any ideas for improvement?
  • A non-static String.format method.
    How often did I start with a literal String only to find out I had to move the cursor back to the left and put "String.format(" in front of it? It would have been easier if the format method were an instance method. Compare:
    String.format("Message for %d %s items", 5, "red");
    "Message for %d %s items".format(5, "red");
Please share you thoughts.

Saturday, July 22, 2006

Expert Spring MVC and Web Flow - Book review

I just finished another book: Expert Spring MVC and Web Flow. This time I really enjoyed reading the book. The tutorial and the example applications distributed with Spring are excellent, but to get a good feel for the complete Spring MVC this book is a gem.

Here are some of its strong points:
- The book has clear subjects per chapter (an obvious requirement, but not always met).
- Your time is not wasted; the language is concise without being to cryptic. Really, the books reads as if it has been reviewed and corrected by at least 30 knowledgeable persons.
- You're not coerced in how you must use Spring MVC, but you're told how to make the appropriate choices from the options Spring MVC provides.
- The book not only shows you how stuff works, but also why, learning you valuable design principles that stretch way beyond Spring MVC.
- The appendix on DWR integration is short but very sweet.

Some minor nitpicking:
- The books regularly refers to Spring 1.3, though by the time of writing it was already known that version 1.2 would be followed by 2.0 (the chapters on Spring Web Flow have this correct).
- There is no information on the new form tag libraries.
- There is no mention of Spring Portlet MVC, except for a short reference in the chapters on Spring Web Flow. (Note that you'll find switching from Spring MVC to Spring Portlet MVC quite easy.)

If you are considering learning another web application framework: buy this book.

Tuesday, July 11, 2006

Writing CSV from Java

I recently tried to find a open source Java CSV writer released under a commercially friendly license. To my surprise I could not find one.

CSVs are still the easy solution when you want to export to any spreadsheet program. The only big problem is getting it right for Excel as Microsoft has its own opinion about CSV.

Anyway, since I did not find any, I wrote my own. It has the following features:
- streaming output (big files are no problem)
- uses Java5 printf formatting for flexible column formats
- settable separation character, locale and encoding
- verifies numer of columns

I also wrote a View implementation for use in a Spring MVC environment.

Here are some possible improvements:
- more automatic support for different Excel versions (dependent on locale)
- introduce a CsvWriterFactory to enable easier Spring wiring

I don't think my employer would minds if this went opensource. For example with an Apache license. Anybody interested?

Update 2007-10-23: I think our troubles are finally over: meet Super CSV!

Thursday, June 29, 2006

Portlet anyone?

Today I have been trying to get a portlet to work. Without success. I could not believe it could be so difficult to deploy this stuff. How can anyone stand this? It's no wonder people run away to Ruby on Rails.

Example: The error message is "NullPointerException".
Translation: please remove log4j.jar from your WEB-INF/lib folder.

Another example: "The portlet.xml could not be found". I am quite sure the file is there! Cause is yet to be found. Some pointers I found told me to check 4 other files. I did, no idea yet what could be wrong there.

Please spare me from more JCP junk.

(For those interested: I tried to run the Spring MVC portlet example in Pluto 1.0.1. I made one change: the name of the application.)

Update I know, I know. It is not fair to criticize open source projects. There are actually people that put their heart in this kind of stuff, and they deserve appraisal for it. Unfortunately I am now in the situation where I have no choice and actually have to use an under documented Pluto version.

This morning I found I overlooked yet another Tomcat log file (localhost.log) in which there were clear class not found exceptions. These provided enough pointers to get things running pretty quickly.

Saturday, June 17, 2006

Spring One

The fast facts:
  • 50 presentations
  • 400+ visitors from over 24 countries
  • Spring 2.0 to be released very soon
    • excellent JPA support
    • AspectJ fully integrated (without special compiler)
    • finally a form tag library in Spring MVC
    • improved xml configuration
    • asynchronous JMS facilities
    • many many small fixes and improvements
  • word count
    • EJB3: 0 times
    • Java Persistence API (JPA): zillion times
  • BEA is building WebLogic 9 series on Spring
  • Spring in use in ultra-safety focused companies like Voca
The last 2 days I have been to the first ever Spring-One conference in Antwerp, Belgium. It was an exciting experience to see all the core-developers of this excellent piece of software in one location. Unlike at the JBoss World conference in Barcelona, Spain half a year ago, I felt a friendly and respectful atmosphere from all speakers. The enthusiasm was actually contagious and let me to believe there is still lots of hope for the Java environment.

Remarkable is that besides the obvious talks about upcoming Spring 2.0 there was also quite some focus on Domain Driven Design or Rich Domain Modeling. Perhaps Interface 21, the company that employs many of the important Spring developers, wants to emphasize that they are very capable in providing advanced architectural consulting services.

The best practical I have seen was the JPA testing demonstration by Rod Johnson. With some black class-loader magic Spring makes in possible to quickly test JPA based DAOs and repositories against a database. And by quick I mean quick: several hundreds of tests in only 5 seconds on a simple laptop.

Though not all presentations were great, most were. I think I got a lot of value being at the conference.

Update: Chris May has a nice and extensive blog on Spring One.

Presentation materials are available from the Spring one website.

Saturday, May 13, 2006

Ajax in Action - Book review

Last night I finished reading Ajax in Action. And although I have great respect for the authors' abilities, I found it to be a disappointing activity. Please read on why it may still be the book for you.

I found the book lying around on a table at my office. To prevent being the last developer in the world doing something with Ajax, I thought I'd better read it. Initially my heart jumped when I read the mini JavaScript introduction in an appendix. As a hard core Java programmer (with teachings in diverse range of currently somewhat old languages) I was completely in the target group. I found out that JavaScript is really different with respect to a lot of other languages and that I must have done some horrible wrongs in my previous JavaScript ramblings. However, this was my only really positive experience with the book.

The first chapters of the book were still okay as they give a nice overview of the Ajax world. In addition they managed to tell me how to do requests from JavaScript directly (the XMLHttpRequest) and how to handle the responses. I did not know much about this. The later chapters work out some very specific things which may be interesting if you currently need to build those. Some frameworks are touched upon, but never described more in any detail.

My main complaint about book is that it contains lots of descriptions of what you will be able to read instead of just giving it to me directly. It takes a lot of text to get to the point and when it gets really interesting you're referred to somewhere else. Equally interesting is that the code examples are almost all completely lacking any comments which is compensated with tedious descriptions of that code.

In conclusion, this book may be for you if 1) you need a good overview of what Ajax is about (first chapters), or if 2) you are already a good JavaScript programmer, have plenty of time to read the book and then some more to the understand the frameworks you inevitably need to use (with which you may have started with in the first place).

Wednesday, May 10, 2006

CMS blues

Somehow CMS systems always have disadvantages (even the ones I wrote myself e.g. BackStream's ECMS :) ). They are always of one or more of too proprietary, too large, too strict, too flexible, not multilingual, without workflow, too data oriented (instead of task oriented), too hard to configure, too hard to program, too slow, too ugly URLs, too etc. etc.

I am currently looking into a Ruby on Rails CMS called Radiant. So far it has the following pros:
- it is nice to look at
- it is still small
- it pretty powerful while still easy to follow (possible thanks to Ruby)

It still needs a lot of work. For example there is currently not even support for images and stylesheets. Still the way things are structured make me think this CMS will come a long way towards the ultimate CMS. Lets spend some more time on this...

My first post

My first post. Lets just see what will come out of this blogiething...