Thursday, September 21, 2006

Textile Quick Reference

I started using Textile and Enscript for blogging but found no quick reference for textile so I wrote one.
h1. H1
h6. H6
bq. blockquote
[1] footnote ref
fn1. footnote def
_word_ em
*word* strong
??word?? cite
@word@ code
-word- deletion (strike-through)
+word+ insertion (understrike)
^word^ superscipt
~word~ subscript
p<. align left
p>. align right
p=. align center
p<>. align justified
* bulleted list ( may be nested * *)
# numbered list ( may be nested # #)
"Google": Link to named Google
"Google":alias Link to alias named Google
[alias] Alias definition of alias
!image! Image
!image!:http:// Image with link
!>image! Image aligned right
CSS(Cascading Style Sheet) acronym

Sunday, September 10, 2006

Closures in Dolphin

A proposal for adding closures to Java has been crafted by none less than: Gilad Bracha, Neal Gafter, James Gosling and Peter von der Ahé. With proponents such as these I have high hopes that Sun will finally see reason and include it JDK7. Our state machine:
interface Condition {
    boolean isFulfilledBy(Event e);

interface Action {
    void perform();

interface State {
    void addTransition(Condition condition, Action action, State nextState);
is used like this to set up a two transitions:
         new Condition() {
             public boolean isFullfilledBy(Event e) {errorService.hasErrors();}
         new Action() {
             public void perform() {logMessage());},
         new Condition() {
             public boolean isFullfilledBy(Event e) {((BootEvent)e).isStarted();}
         new Action() {
             public void perform() {displayIdleScreen();},
It can now be cleaned up to look like this:
bootState.addTransition((Event e){errorService.hasErrors();}, (){logMessage();}, errorState);
bootState.addTransition((Event e){((BootEvent)e).isStarted();}, (){displayIdleScreen();}, idleState);
Since most of our flows consist of many states and more transitions our code will become a lot more compact and easier to read. The code above will work without any changes to our state machine API. The reason for this is called closure conversion and it basically allows you to use any class with one abstract method with closure syntax. The typical usage is interfaces with one method but abstract classes with one abstract method will probably also be allowed. I'm looking forward to Dolphin. The verbs are finally making their way into the kingdom of the nouns.

Friday, September 08, 2006

Six Months with Eclipse

The last six months I have spent working exclusively with Eclipse on a OSGI based project. My editor of choice is IntelliJ IDEA but since everyone on the project are using Eclipse and it‘s OSGI features I figured I would give it a go without complaining (too much).

The project makes heavy use of OSGI components and since Eclipse is built with these components it should fit like a glove. OSGI component metadata, such as dependencies and published interfaces are defined through extensions to the standard jar-manifest file. Eclipse works well with these components and parses the manifests and updates the classpaths accordingly. All should be well but I miss IntelliJ everyday.

I am a keyboard shortcut fanatic and I like to be able to do everything without using the mouse. The first thing I did when I decided to go with Eclipse was to learn as many shortcuts as I could, print out a couple of quick reference guides and remap mappings I did not like and I am now fairly fluent in Eclipse. Eclipse has a lot of wondeful features and plugins (such as multi-clipboard) but IntelliJ excels. I can‘t say that everything is better in IntelliJ, but it is better at the little things that matter. It anticipates what I want to do and helps me do it when I want to. I behaves the same way no matter what kind of file I am editing. There are no surprises! If I think of something and try it out it usually works the first time.

To illustrate my point I‘ll give a few examples: Cut text (Control-X): Cuts the selected text into the buffer, but if no text is selected it works with the current line.

Context-Selection (Control-W) inside a string: Press once: a word delimited by non alphanums is selected, again: the full string without quotes, again: the full string including quotes, again: all parameters of the enclosing method call, again: the enclosing method call excluding semi-colon, again: the enclosing method call including semi-colon, again: the full line, again: all lines in the block, again: the enclosing block… And it works the same way inside XML, Javascript, JSP etc. If you try this in Eclipse there is no telling what will happen depending on file and context.

Go to class (Control-N), Go to file (Control-Shift-N) When you, while typing the search criteria, remember that it is not a class but an XML file you want to look up you just press Control-Shift-N and IDEA remembers what you typed in and starts looking for a file corresponding to what you typed.

These are just few little things that make a big difference. There are hundreds!

Eclipse is free! It is Open Source! It has loads of usable and cool plugins! I want to want to use it, but I don‘t since it is not good enough.

The Rise of Anarchy

At the end of the second millennium, Gregorian time, there was one major method that ruled the software industry. This method was known as the Common Rigid Artificial Process: CRAP. CRAP was a unification of three moderately successful competing methods that specialized in Object Oriented Design. The competition kept their methods from becoming overly bureaucratic.

At some point in time, the founders of the three methods, the Three Bandidos as they became known, decided that they would profit more from creating a monopoly than from competing. They assembled their methods and it became CRAP.

CRAP dominated the industry, because the three bandidos were hugely successful in both modeling and marketing, and all the major industries quickly switched to it.

Now the healthy competition between the bandidos was gone and they relished in bureaucracy. Thousands of people were using CRAP without getting anything done. If you asked anyone what they did today, they would say they produced some CRAP document that was required by the method and at the end of the day no one remembered what the goal was in the first place (to produce software). The bandidos didn‘t mind, since their goal was to make money and not software and they became wealthier and wealthier. Their future looked bright.

A New Beginning

But at an AA meeting in Utah a number of anarchists started a reactive movement against CRAP. They were fed up with producing artifacts of no value instead of real working software. They wrote the Anarchistic Manifesto and created the Anarchistic Alliance. They called it the Anarchistic Alliance so they could keep referring to it as AA in their correspondence, since they were afraid of repercussions from the CRAP affiliates.

Because they were anarchists, they could not agree on one single method that should suit all. Instead they decided to let everyone define their own method as they saw fit. The important thing was that the method had to be built on individual cooperation, instead of totalitarian hierarchies. Every individual had to take responsibility for what they were doing! No one could tell anyone else what to do! When large systems had to be produced, it had to be done through the voluntary formation of teams that would voluntarily cooperate with other teams. Informal leadership would be the rule, instead of the assigning of roles.

Before the CRAP people could do anything about it, the anarchist had infiltrated much of the small businesses that were now being targeted by CRAP. The anarchistic methods worked so well that there was no one willing to give them up in favor of CRAP. To stop the spreading of the anarchistic methods, CRAP started to make unfounded claims of how they could be used. Since they were currently only used in small and a few medium businesses, CRAP propagandist claimed that the methods would not scale. This claim was successful at first, since many people in the major industries had invested considerable amounts of time on becoming experts of the CRAP bureaucracy.

The Turning Point

Even though the propaganda worked for a while, many of the medium businesses that used CRAP went bankrupt. They did so because the software they produced was expensive and inferior to software produced by smaller but more effective firms. Soon, all the medium businesses threw CRAP out along with CRAP consultants.

At this time the large industries were still unaffected by the anarchists. They were buried too deep in bureaucracy and were also dependent on CRAP tools. This is where the CRAP people made a fundamental error. Instead of keeping up appearance and continuing to claim that anarchistic methods does not scale into large businesses, they flip-flopped. They claimed that CRAP was anarchistic! What a gargantuan mistake! Instead of making the medium industries move back to CRAP, it made the major industries realize that they had been fooled all along!

The major industries threw CRAP out as soon as they could. The expensive CRAP tools were replaced by cheaper and better alternatives and the rest, as they say, is history!

1. Anarchy, contrary to popular belief, means "absence of ruler" and not chaos.