What’s missing in Java 7

Assuming Sun manages to get “closures” into Java7 there is still a few things that are lacking. Today I once again ran into the restrictions around annotations. The .Net solution is simply more elegant. The fact that I can’t use arbitrary classes for annotation parameters is arbitrary and promotes widespread abuse of enums. Also that these guys aren’t regular classes with methods and all is quite annoying.

Using arbitrary classes as annotations would actually make the language simpler and is therefore good…

Documentation on Presentation Model Pattern

Here some links to the pdf and the sourcesfor my tutorial.

Im Namen der Deutsche Bahn AG…

… begrüße ich Sie ganz herzlich an Bord der Ersatzgarnitur 2809.

Deploying on Windows

I spent the best part of this week on doing remote deployments to a jboss server running on Windows. Don’t ask why I am doing this. But there is an intersting observation about psexec. It doesn’t work reliably when called with redirected io, e.g. from the awesome TeamCity server.

Apparently there is a fix, which is using RemCom.exe, which in turn is somewhat neglected these days.

Lesson learnt: windows is not built for relentless automation.

Jour Fixe Zubehör

Bin schon vor längerem über dieses Design gestolpert. Leider scheint es nicht produziert zu werden.

Practices of the Proper Christian Programmer

This post is to announce the publishing of “Divine Code – Practices of the Proper Christian Programmer”.

Whilst more or less appropriate commandments have a long standing tradition in software development – one of the first examples being Dijkstra’s famous “Goto Considered Harmful”, little has so far been written about sound practices in God fearing development, that acknowledge the necessity of a strong faith and recur to the spiritual experience of two millenia.

The authors provide us with a step by step introduction to the practices that could very well be used as a maturity model.

They start out with the practice of Prayer. Praying has a long standing tradition in software development – the steps pray and deploy are part of every serious continuous integration effort. It is now well understood that the power of the prayer is – not unlike TDD – twofold. There is a direct effect when the spirit enters the code base as well as an indirect effect through the changed mind-set of the developer. Some pagan processes do rely on daily standups as a substitute for prayer. These efforts might be well-intended but do nonetheless amount to heresy!

Further practices include Christening, which involves getting your system properly soaked, the Holy Communion formerly known as team drinks, Exorcism which comes in different degrees ranging from the casual refactoring to a full blown rewrite. When all that could be done has been done the Annointing of the Sick Code Base could be your last resort.

Another practice that has recently been falling into misuse by heathen folks is the Sacrament of Reconciliation aka Confession. The godless call it retrospective though.

Peace of mind is essential for the productive programmer and can easily be achieved with the firm believe in the Project Everlasting. Everything else failing there is always the option of applying the time honored practices of Crucifixion or Stoning to the incompetent manager or customer, though the authors concede that in most cases generous amounts of Holy Water and Incense will do.

In the true spirit of inclusiveness and diversity there is a contributed chapter on Halal coding Habits, that provide an even more elaborate mental frame work for the aspiring programmer, vividly illustrating that Christianity is not the only hope for the industry. Halal actually meaning lawful or permitted our knowledgeable co-author makes a good point that doing the bad stuff makes the project go haram – unlawful. Another interesting point is his elaboration on the importance of a prophet between the mere mortals and the divine, incomprehensible supreme being. This indirection has indeed come to us in the form of asynchronous messaging with a certain BizTalk combining these virtues with the agile virtue of talking to the biz.

The book is available as of today, April 1st 2010 – let the lord in to your heart. Buy a copy. And become a truly superior programmer.

Use Jetty!

I was somewhat shocked to learn that a lot of my colleagues are not even aware of the existence of jetty. I have been using it for quite a while. It is the best thing you can do during development – and no jboss is not a good thing it is after all quite similar to websphere. Arguably jetty is also the best thing in production.

As I will die one day, I can’t be bothered to use anything else, because there are no insights to be gained and no problems to be solved by using anything more “elaborate”.

Schön Sperrige Wörter

Lautstand bezeichnet in einer diachronen oder diatopischen Betrachtungsweise das gesamte System von Lauten einer Sprache. Wenn sich der Lautstand, meistens über einen längeren Zeiträume hinweg, verändert, so spricht man von Lautwandel. Oftmals unterscheiden sich Dialekte einer Sprache durch den Lautstand.

-Wikipedia

Working Effectively with Legacy Code

I have just finished reading Michael Feathers’ Working Effectively with Legacy Code. The book gives a lot of very concrete examples of how to improve code and make it testable. To my tastes he is exaggerating the whole code without test is legacy code thing, which in the naïve reader might lead to the impression that a test is all it needs for code to be good.

As I am going to sell my copy at favourable rate to one of my colleagues, I’ll just list a few things I found intersting:

  • Chapter 15 – My application is all API calls. He uses a very good example of a mailing list server to illustrate how to get around problems with external API dependencies. He distinguishes to approaches “Skin and wrap the API” and “Responsibility-based extraction”. I am strongly favouring the second approach as I find it leads to more relevant abstractions and not wrapping for the sake of wrapping…
  • Another theme in the book is understanding code. He mentions a few nice techniques:
    • Effect analysis (dataflow analysis) using pen and paper
    • Mapping out your way through the code base while reading on a piece of paper
    • Printing the code and doing listing markup using marker pens.
    • Scratch refactorings while reading code, that are thrown away and whose sole purpose is helping to understand the codebase and on a similar note delete unused code you find while reading
    • Telling the story of the system. This is done at several levels starting with a high level description that has a lot of generalisations. This practice helps people to develop a shared vision and also highlights discrepancies between the system and the story.
    • Naked CRC-Cards – somewhat poorly named as actually it’s naked object cards. Use white index cards on a table to represent objects. Tell story as you place and rearrange them.

There is a nice example for separation of concerns (he uses the term SRP, which I don’t like) on page 247 describing an expression evaluator.

Adapt parameter refactoring. If the parameter type is too complicated for stubbing etc, look at the use of the parameter and introduce a wrapper around the original object that just exposes what the current method needs. Example HttpServletRequest gets wrapped in ServlatParameterSource which implements a new ParameterSource interface.

On a similar note primitivise parameter. Instead of passing in our wrapping an expensive abstraction just pass in the required “values”. This of course very dangerous as it breaks encapsulation. On the other hand it could lead to the extraction of roll based primitive interfaces (a bit like the adapt parameter pattern)

Unconditional Success

Before I forget it completely, I have to post a link to Nick Williams’ Unconditional Success. This book is outrageously funny. We kept a copy on our desk and would open it at random pages to reinvigorate the team spirit.