Programming is hard by Stephan Schmidt

100% test coverage for Swing and database apps

A recent post about in-memory database unit testing by Mike Bosch reminded me of a presentation I wrote but never published about developer testing and how to achive 100% test coverage for nasty applications. High test coverage for most parts of an application is easy, for some parts it’s difficult to do. The hard parts are Swing parts (which Jemmy can help with) and database parts (which hsql in-memory can help with). With the tips and tools in the presentation it’s possible to reach 100% test coverage. But I conclude that most of the time 100% test coverage not needed.

cintoo Messages moved to Java 5

I moved cintoo Messages to JDK 1.5 because of several reasons. I know this will reduce the potential user base, but with Mustang on the horizon, a lot of projects are moving to 1.5 now or in the near feature. Beside I really like generics (being a strong opposer for some years, though IDEA could make code less noisy and hide generics completely) and Java 5 has varargs and outoboxing. This makes dealing with String formatting much easier.

Instead of:

format(”{0} of {1} files removed”,
new Integer[] { new Integer(3), new Integer(7) });

(there was a helper in Messages which took int[] )

now you can write

format(”{0} of {1} files removed”, 3, 7);

which is mapped to

public String format(String text, Object… args);

The Object… is syntactic sugar and is automatically mapped from “3, 7″ to Object[] with
autoboxing 3 and 7 to objects.

Those Ruby Google trenders again

Those ruby google trenders again. As said before, if everyone is already using Java, noone will search for “Java” in Google ;-)

The search volume is basically the increase in mindshare, not the mindshare. So Java has probably much more mindshare than AND the mindshare is increasing twice as fast. And if you search for ruby alone in Google trends, then it’s clear that a lot of search volume comes from the word “ruby” not from people searching for the programming language (News found for Ruby includes “Ruby’s remount row rumbles on”, “Ruby Tuesday, Inc. Reports Second Quarter Diluted Earnings Per Share of $0.28″ … Compare this to the Java news which mostly concerns the Java programming language)

Ever more complex software stacks

In the last 30 years the software stack has grown from year to year. When I started coding in Z80 machine code, there was no software stack. Just the programmer and some hardware registers. No other software involved. Direct access to the machine. From there software stacks grew, to compilers and libraries. With Java the stack grew to JIT compilers, virtual machines, garbage collectors, byte code compilers and plattforms. To close the gap between the machine and the customers requirements one solution for many seems to be to grow the software stack even further. With MDA and containers the software stack grows to unprecented complexity. From PIM with transformations to PSM to a Java EE container, with AOP and compilers to Java, with byte code compilers to the VM with GCs. Then with JIT compilers to machine code (and from mc to microcode). Where will the stack move next?

Customer and Machine Gap

Why Grails instead of JRails

The JRuby team has accomplished an amazing thing, running Ruby on Rails with JRuby. So is Grails dead? No! Why should someone then use Grails and not JRuby on Rails? Ruby is a very nice and clean language, Rails has a lot of extensions and documentation. But Groovy is more similar to Java, like Java on steroids, is tighter integrated and has more appeal to Java developers. But to quote Oracle “at the end what you generate with Grails is a J2EE app, web container managed and deployed. You can manage it in the same way you manage any other J2EE app.” via InfoQ.

Update: I really like Ruby :-) I’ve written a Ruby OR Mapper called Ruby.RDO and a web framework called Ruby.RO more than 4 years ago which focused on ease of use and components (think tapestry).

Maven javax.mail broken?

Maven doesn’t find javax.mail, it resides in javax/mail/mail in the repository, shouldn’t that be just javax/mail ?

Update: Yes I know with groupId = javax.mail it works, but shouldn’t that be just javax?

XmlResourceBundle added to Messages

I have added a XmlResourceBundle to cintoo Messages.

<properties>
<property key=”mykey”>myvalue</property>
</properties>

The greatest benefits with XML are that you can easier use encodings in XML files than in the default Java properties bundles. And you can use XML-based tools for bundle creation and management. The bundle also shows the direction Messages is going. Easy adobtable to your project requirements.
The XmlResourceBundle is easy to extend. As an example for another Xml properties
format I chose one from Cocoon.

The format is different from the default properties xml format in Messages, so some adaptions are needed.

<categories>
<message key=”mykey”>myvalue</message>
</categories>

Messages xml uses Apache Jakarta Digester. We have to tell Digester how to map the xl tags to the properties class.

public class CocoonXmlResourceBundle extends XmlResourceBundle {
public CocoonXmlResourceBundle(String baseName, Locale locale) {
super(baseName, locale);
}

protected Digester configure(Digester digester) {
digester.addObjectCreate(”catalogue/message”, Property.class);
digester.addSetNext(”catalogue/message”, “addProperty”, “cintoo.messages.bundle.xml.Property”);
digester.addBeanPropertySetter(”catalogue/message”, “value”);
digester.addSetProperties(”catalogue/message”, “key”, “key”);
return digester;
}
}

That’s it. And it’s as easy to adapt XmlResourceBundle to other formats.

Beware MacOS X Java developers

At least all of those as stupid as I am. When developing cintoo Messages I got biten (again!) by the MacOS filesystem not being case sensitive. All tests worked fine but on the integration server (thanks pulse guys for providing your software, it helps) which is running on Linux the tests wouldn’t work. My bundle files were called test_de_de.properties which worked on MacOS X but not on Linux, where they have to be called test_de_DE.properties. Well well, write once … ;-)

Of course I recognized this after a long debugging session which even drove me to download the JDK source. Sigh.

Funny stuff: Rules for Rails comparisons?

There is a funny satire demanding rules for RoR comparisons called ‘Six Ground Rules for “Rails Sucks” Articles’. Really funny stuff, go read it. But everyone knows there are only the Queensbury Rules.

Google trends proves: Java is doomed

Google trends is a nice idea, and I had to apply it adhoc to Java, Ruby, Python and C#. Interesting results, I can see a decline in Java! We’re doomed :-)

And the Rails evangelists jump in and present this. Probably people would search for that or even that because Rails mostly doesn’t find RoR though. All others ignore the quabble and use Jetty or Grails.

For fun try this.

Update: Searching for Web 2.0 creates a nice graph and close to my heart: wiki.

Is werx dead?

Werx is a type safe intra-application message bus in Java. I’ve been a happy werx user for a while, but when I headed back to the werx website the developers obvisously haven’t renewed their domain (downloads can be still found on the werx sf website;). The developers aren’t answering questions, so is the project dead?

Just one thing about language shootouts

Lately I’ve been reading Just one thing. This is not only an excellent and enjoyable book about investing money, but there are some essays which are beautiful written and interesting for software developers. There is an essay about biases of investors. All those biases apply to software developers when they talk about their tools and about which I’ve written before.

The most interesting essay is by James Montier and is called “Psychology matters”. He quotes the main areas of biases an investor shows as Self-deception, Heuristic simplification, Emotion/affect and Social. The emotion bias certainly applies to software developers and the heuristic simplification is apparent. There are no heuristics, facts or numbers in tools, processes, language and framework comparisons, just guts. And it doesn’t matter if you take the RUP/XP discussion, the writing/generating (MDA) discussion, the Java/Rails discussion, the Groovy/JRuby discussion, the text/graphics (UML) discussion, the Spring/Java EE, the action (WebWork)/component (Tapestry, Wicket)/continuations (RIFE, Seaside) discussion, the static (Java)/dynamic (Script) discussion, the open source and license discussion or one of the countless others going on right now about what is the next big thing.

Though the most important bias seems to be self-deception. Under self-deception he lists Overoptimism, Illusion of control, Illusion of knowledge, Overconfidence, Self-attribution bias, Confirmation bias, Hindsight bias, Cognitive dissonance and Conservatism bias.

And while he’s talking about investors, all those can be applied to language evangelists and their high priests. Overconfidence comes from people with few projects. Self-attribution is their way of attributing success to their skills and tools while it was plain luck. The best quote about tool evangelism in the essay is “Heads was skill, tails was bad luck.” And overoptimism is the one thing that describes software developers best while illusion of control plagues most managers of IT projects.

So next time you read about how successfull a tool or framework is, think about the biases the author has fallen for. Good luck.

First version of cintoo Messages 1.0 released

After some months where the source hibernated on my hard drive, I’ve packaged and shipped it at last. The first release of Messages is now available. Messages is a open source framework to make internationalization easier for Java applications. It supports locales for threads and bundles can be associated with different packages. This allows the usage of different bundles for different parts of the application like plugins, installer or logging. Bundles can be managed and associated with packages without any changes in the code. This makes bundle management and refactoring much easier than with other solutions.Messages supports global locales for client applications written in Swing or SWT and thread local ones for serverside web applications.

Cintoo Messages is Apache 2.0 licensed.

http://www.cintoo.org/messages

Rules for a successfull business

The rules for a sucessfull business are easy:

  • The customer is the most important thing in your business
  • The best business plan is to sell people the things they want
  • Your business is successfull if your earnings are higher than your spendings

Sounds easy, most startups forget all three of those rules.