Ruby DSL’s vs YAML vs XML

Monday, May 14th, 2007

I am using Ruby based DSL’s for a number of tasks in my current project. But one day it struck me - am I using the right tool for the job, could there be a better, more simple solution?

Some DSL’s I use are simply declarative and look something like this:

I find that quite readable, but it requires me to maintain code that handle the DSL. So I figured, what if I used YAML? It is simple, and using it would mean less code to maintain.

After doing some experimenting, this is what I came up with:

In my opinion, the YAML is not as readable as the Ruby DSL. I also find it more error prone as those dashes are sort of tricky.

XML?

With the correct schema, errors can be avoided, but it is just too much text in there, it gets heavy and verbose.

The verdict was to stay with the Ruby DSL’s - their readability and flexibility are well worth the effort of maintaining a separate parser - which is quite short really.

Another Mercurial Convert

Tuesday, April 17th, 2007

Paul Duncan is another Mercurial convert, and explains his choice of VCS very well

Spring Is In the Air

Tuesday, March 13th, 2007

Spring surprised us early this year, so we are currently blessed with a mild 10ºC. As everyone who has ever experienced it knows, the early days of spring after the long dark winter are just wonderful

stockholm_20070313.jpg

The photo is taken with my SE K610i, and stitched together with DoubleTake, which deserves a mentioning. I noticed today that I had lost my license for it, so I sent an email to EchoOne explaining the situation. I got a reply with my license within 4 hours. Great stuff.

Google Apps - Heaven and Hell

Tuesday, March 13th, 2007

We’re using Google Apps at Re:mind which is really, really great. So great in fact that I wanted to move my private mail there as well. So after setting the domain up, I created the webpage that was needed for domain activation, put it on my server, clicked the “verify my domain”, and got the usual “this may take 48 hours to complete”

It has now been almost two weeks or something like 300 hours, slightly more than 48. I have sent Google a support email asking what is happening, but I have yet not received an answer. To that mail that is

You see, today I got this mail:

Hello Marcus,

You’ve been invited to use Google Apps for ahnve.com, but we noticed that you haven’t started using any services yet.

To activate Gmail, Google Calendar, Page Creator or the new start page, log in to the control panel with your administrative account. At any time, if you get stuck or if you want to tell us about your experience with this service, you can find more information and get in touch through our help center (https://www.google.com/support/a).

To make room for other domains, we will remove ahnve.com from our system if you don’t activate any of these services in the next two weeks. If you need more time, just click this link: [link] and we’ll extend the deadline to 30 days from now. Alternatively, you can sign up again at a later date when you’re ready to use the service.

Sincerely
The Google Team

Now, isn’t that ironic?

Javaforum in Stockholm Wrap Up

Wednesday, November 22nd, 2006

I spent yesterday evening at Javaforum. Ola Bini held a great presentation of JRuby that really showed what can be accomplished today and what we can expect in the future.

Ola is not only an über hacker, he is a great guy too. When asked what work is done with Ruby in Sweden today, he was kind enough to mention the work we’ve done at Valtech with Rails, which of course got him a well deserved beer later.

The guys from Interface 21 did a so-so job presenting Spring AOP. I might be biased as I have been in AOP-land and left it, but in my opinion their presentation skills were far better than the actual content.

During after-beer Ola and I discussed the state of Java and agreed that the greatest part of the Java platform is the JVM. It will most probably survive Java the language and be a platform for a multitude of languages. It was therefore funny to read Mike Bowlers blog post today about exactly the same thing.

All in all a good evening.

RE: The war is over and Linux won

Tuesday, November 14th, 2006

At least in the server world, Linux has won.

Here in Sweden, Microsoft has an inexplicable stronghold, even in the server room. The last time Craig Larman, Valtechs Chief Scientist, was here he noted that nowhere did he see as large proportion of server side windows as in Sweden - and Denmark.

I don’t know what makes swedes pay for stuff others get for free. Perhaps the high taxes have made us used to money disappearing?

Java is the new C

Sunday, October 22nd, 2006

This could actually turn out to be quite important down the road:

Writing Solaris Device Drivers in Java: “‘We present an experimental implementation of the Java Virtual Machine that runs inside the kernel of the Solaris operating system. The implementation was done by porting an existing small, portable JVM, Squawk, into the Solaris kernel. Our first application of this system is to allow device drivers to be written in Java. A simple device driver was ported from C to Java. Characteristics of the Java device driver and our device driver interface are described.’”

(Via OSNews.)

I am also a …

Sunday, October 15th, 2006

… a talent!

You’re a risk-taker, and you follow your passions. You’re determined to take on the world and succeed on your own terms. Whether in the arts, science, engineering, business, or politics, you fearlessly express your own vision of the world. You’re not afraid of a fight, and you’re not afraid to bet your future on your own abilities. If you find a job boring or stifling, you’re already preparing your resume. You believe in doing what you love, and you’re not willing to settle for an ordinary life.

Talent: 64%
Lifer: 23%
Mandarin: 49%

Take the Talent, Lifer, or Mandarin quiz.

XP 1.0 is better than XP 2.0

Friday, August 11th, 2006

Alan Francis: Jobs, etc.: “[...] being an old-school XP-er who thinks Kent got right the first time and only dug a deeper hole trying to re-explain himself. ”

Well put. XP 1.0 is mostly brilliant, whereas the additional value of 2.0 could could have been published in a short addendum.

Kent Beck is probably the hero of the geeky part of my life and I am sorry to say that I find the quality of his work receding. Whatever he wrote or spoke about before, it was always empirically based and with a very appealing rebel touch. It seems to me that he is becoming more and more theoretical. For example, I found his keynote at XP2006 about “responsible developing” very abstract.

Let’s hope that the book he is releasing this fall proves me wrong.

(Via Planet TW - Alumni.)

Why I don’t like Fit

Thursday, August 10th, 2006

I don’t like Fit. Believe me, I want to like it, I have tried to like it. I mean, Ward Cunningham created it for crying out loud, the man is a genius, so I am probably just missing something - right?

Every time I have looked at Fit, I always like the parts that handle column fixtures. They are clean and easy to read and generally does a really good job. Buth then we get to weird cousin Row Fixture which is not at all that easy to read and uncle Action Fixture which just won’t stop and finally family FitLibrary which does all good things but are utterly unreadble - which probably is due to my lack of experience, but then again wasn’t this intended for non-programmers?

Geoff Bache told me at XP2006 to look into FitLibrary and Erik Lundh suggested that I read the book on Fit. So now I have done just that, and I still don’t like Fit. As a language that is.

What the book did explain clearly, which I find the truly awesome part of Wards invention, is the idea of executable requirements written in advance. It is soo XP that you just have to love it. And I finally get why you should test the logic layer and not through the UI. Happy now?

But the book did not address all my concerns. It does not talk about the problems with version control; if you choose to work with Excel based Fit tests you will not be able to track changes as they are binary files. Neither does it suggest how Fitnesse pages are to be kept in version control. Also, all Fit formats are hard to follow if you track changes by commit messages by email.

The Fit syntax is in my opinion a table based DSL for writing acceptance tests. How many other programming languages do you regularly use that are table based? Excel? It is awesome for column based calculations which is the same as Column Fixtures, which I like. I alreay wrote that. But the rest is just … ugly.

A better solution in my opinion would be a Markdown based documentation format, where code formatted text, the indented one, is executed as tests just like tables in Fit. Could probably easily be turned into a Wiki if needed. For testdata I would use Yaml. Now if I could just find the time :)

XP2006

Monday, June 19th, 2006

I am currently in Oulo, Finland, attending XP2006. I have so far attended really excellent tutorials by the Poppendiecks and Mike Cohn. I am writing this waiting for a session on DSL to start.

This is by far the most social events I have been to, which probably is helped by there only being 200+ people here.

Cedric Still Doesn’t Get Agile

Friday, June 9th, 2006

Update: Martin Fowler pointed to . It seems Cedric did not give us the full picture. I have edited my post accordingly

After attending a less than stellar presentation on TDD, Cedric Beust confuses TDD with “Agile” and goes on to tell the world that agile is not good. Let’s have a look, shall we?

First of all, tests are not specs.  Not even close.  Somebody in the audience was quick to give a counter-example to this absurd claim by using a numeric example (’how do you specify an exponentiation function with a test?’)

I would not use unit tests for specs. Automatic acceptance tests on the other hand is really nice if you have a customer/product owner that will work with you. Now Cedric has previously stated that he does not really care for the labelling of tests (“However, when I write a test, I don’t really care if it’s a unit test or a functional test”) so that of course makes it harder for him.

And hey, testing an exponentiation function? How about providing test data with given parameters and answers? It would be a prime candidate for a FIT-test by the way.

Relying on tests as a design specification is lazy and unprofessional because you are only testing a very small portion of the solution space of your application (and of course, your tests can have bugs). 

Why would you only test “a very small portion of the solution space of your application”?

Tests also fall extremely short of having the expressiveness needed to articulate the subtle shades that a real specification need to cover to be effective.

This is my main gripe with Cedrics rant. He seems to be completely oblivious to the great emphasis on customer interaction that agile methods make, which promotes a two way dialogue.

A specification written in a document is a one way communication. Even in high school psychology I learned how much more information was conveyed in a spoken dialogue than in writing.

This claim is part of a broader and more disturbing general Agilist attitude that is usually articulated like ‘Your code is your spec’, along with some of its ridiculous corollaries such as ‘Documentation gets out of date, code never does’.

What is so ridiculous with the last statement? I have never been involved in a large scale project where the documentation did not get out date.

As for the code being your spec: when you have code and documentation, and the latter does not correctly describe the former, it is out of date, which will you trust? And what do you read to know what the real world looks like? Map, meet terrain.

I am currently getting acquainted with a brand new project that is not even very big, and while I understand Java fairly well, there is no doubt in my mind that for ten minutes I spend trying to understand how a certain part of the application works, a five-line comment would have given me this knowledge in ten seconds.

Sure, if it is up to date, which you will have to read the code to find out. My general rule: if you feel the need, comment on why the code does what it does if it is not obvious. If you feel the need to comment on what the code does, the code is not clear enough. Refactor until done.

Very often, Agilists simply forget that their job is to produce software that satisfies customers, not software that meets some golden software engineering scale.

Again, this is simply ridiculous - all agile methods try to get customers as close as possible to produce just what they want. Anyone even remotely knowledgeable with agile methods knows that.

Frankly, it takes all of ten minutes to explain Test-Driven Development to a developer who’s never heard of it:  ‘Write a test that fails and doesn’t compile.  Make it compile.  Then make it pass.  Repeat’.

I actually find it quite hard to get developers to grasp TDD; people find testing something that does not exist confusing. This is of course the basis for behavior driven development, but let’s just be happy for Cedric now.

Some might find it picky, but leaving out ‘refactor’ in the TDD loop tells me that you somehow has not grasped the concept completely. But then Cedric might throw in a comment instead :).

‘What should we test now?’

‘How about:  if we pop an empty stack, we get an exception’

‘Mmh, no, let’s not do that’

This is quite easy to test, so I do not see why he could not add it. Read Jeffs answer

 
Stack s = new Stack();
try {
  s.pop();
  fail("Should not get here");
}
catch (Exception e){
  //Ignore
}
 

But I am dead sure Cedric knows this , too bad the presenter did not.

To be honest, I am becoming quite suspicious of Agile practices for that reason:  all the presentations I have attended and books that I have read are always using toy implementations as examples.  Stack, List, Money, Bowling…  enough already!

Ignoring the fact that Cedric again confuses TDD and agile, he does have a point. Too many TDD presentations uses examples that are way too simplistic. They should point out the need of a modular architecture, and the fact that using TDD actually helps you get a clean, high cohesion - low coupling architecture.

And please, avoid smug and useless answers such as:

‘A lot of the classes I have to test are hard to isolate, do you have any advice regarding mocks?’

‘Well, if you had started with TDD in the first place, you wouldn’t be having this problem today’.

It is certainly not a helpful answer, but it is true nonetheless.

Fundamentally, I am disturbed by the Agilists’ dishonesty when it comes to presenting their arguments.  They offer you all these nice ideas such as Test-Driven Development and Pair Programming but they never — ever — disclose the risks and the downsides.  To them, Agility is a silver bullet that is applicable in all cases with no compromises.

Just to give one example, “Practices of an Agile Programmer” clearly states that agile is not for everyone.

The truth is that these practices come at a price, and for a lot of organizations, the price gets high very quickly.  Agile development will never go far if its proponents keep ignoring these organizations and make condescending comments to its members.

Here Cedric is spot on. Yay!

I like Test-Driven Development.  I really do, and I’m fortunate enough to work on a project that lets me use TDD most of the time.  But the truth is:  at times, I don’t do TDD because implementing a feature quickly is more important than a fuzzy feeling.  And I’m also aware that TestNG is an open source project with less than five developers, all of them on the bleeding edge and aware of the latest advances in software engineering.

And this is my main beef with Agilists:  I strongly suspect that most of them are spending their time on open source projects with like-minded fellows, but none of them have any experience what companies whose survival depends on shipping software have to go through to organize huge code bases growing thousands of lines of code every day under the combined push of hundreds of a developers, all with their personal background, education and bias.

My main beef with people opposing agility is that they basically say that too many of the developers out there are morons who cannot perform unless closely supervised and given clear instructions, and that there is no hope that that will ever change. It is a weird combination of pessimism and elitism

Now Cedric has a history of not liking agile methods, and that is fine with me. Whatever makes him happy. But his retoric in this case is like watching somebody who does not know karate perform a round house kick - lots of power and effort but misses the target completely.

Don’t trust the non-programmers to design systems

Monday, May 22nd, 2006

I read an article the other day about a surgeon who said that in order to stay a good surgeon, he had to perform operations on a regular basis. Which sounds quite reasonable right?

Ponder that the normal thing for experienced surgeons was to not take part in the actual operation. Instead, they analyze the patient and decide what should be done in great detail, creating diagrams explaining the situation.

The actual surgery is then performed by somebody else, while the surgeon architect at best is standing by in the vicinity, but is probably somewhere else planning the next operation.

It does not work that way. Why do we in the software industry let people who do not program design systems?

Screencasts with Wink

Wednesday, June 15th, 2005

I’ve tried a few tools to do screencasts, my favorite so far is Wink.

Notable features:

  • Easy to use
  • Manual capturing
  • Insertion of text into images
  • Multiple export formats

Hackers & Painters

Monday, April 11th, 2005

Like so many others, I have read Hackers and Painters by Paul Graham. And, surprise, I find it highly recommendable, like everybody else. The following are a few thoughts about I jotted down while reading:

  • Why, oh why, in the name of mad page flipping are the footnotes placed in the back?
  • I am surprised that Pete McBreen of Software Craftmanship fame is not mentioned - in my opinion they are making the same case against “Computer Science”
  • Contrary to common XP belief Paul Graham favors code ownership. Quite unusual in this day and age, and interesting - I need to reflect on it more.
  • His thoughts on developers needing empathy are spot on. Not only for the end users but also for the later developers. It is also better to tell a developer to see things from somebody elses view and document accordingly instead of having him follow the RUP Deliverable Tablets of Stone without reflection.
  • Hosting your own web application - I wish. Companies today still see the intranet as something that should be inside their own, very physical, walls. And I can’t blame them - at Lecando we run our own JIRA, Confluence, SugarCRM etcetera in house. It hit me though when thinking about this - what would we choose if Atlassian offered a hosted JIRA at a competitive price? What if that was the only way they offered their solution? Would JIRA be developed faster since they did not have to worry about releases and customers maintenance problems, or would they spend that time managing the server park?
  • Paul Graham makes a very strong case for capitalism. Whatever your view on politics - I believe that the starting part of the Wealth chapter describing the difference between wealth and money should be taught to all.
  • The parts about Lisp are quite tiresome. And regarding Perl as a higher level language than Java? Please.
  • With “Partisans of permissive languages ridiculing the other [preventive languages such as Java - my note] as “B&D” (bondage and discipline) languages” Paul Graham wonders what “prevent”-style people say of Perl? At Lecando we normally just say “Perl …” and shake our heads.
  • Paul Graham has a slightly dismissive tone when talking about stuff like object orientation, static typing etcetera which can get on your nerves if you are a Java head.
  • I get the feeling that he sees Java people the way Java people see VB people. Prejudice! :)
  • He suggests that pointy-haired bosses select Java for programming projects. Since I would select Java for many programming project, would that make me pointy-haired?
  • He does explain, perhaps unintentionally, Javas success by emphasizing the importance of existing libraries for a programming language to succeed. Hibernate, Lucene et cetera anyone?.
  • When he mentions the importance of efficiency and the ability to rewrite code I believe he is right. But, I can be dead wrong, I imagine Paul being a Emacs hacker, and if you still only use Emacs, it is sure easier to write code in Python, Ruby etc. But in Java land there is this neat thing called refactoring IDE’s - Eclipse, IDEA and the lot. My problem is that it is hard returning to Emacs after using a code-completing, refactoring IDE like IDEA.
  • I guess I have to learn Lisp to see what the fuss is all about

Edit: Fixed typos

Saying hello to our old friend Ant

Friday, February 11th, 2005

Alef Arendsen ponders on whether to switch from Ant to a Ruby build tool. At Lecando we just this week finished migrating away from a Ruby based build system we called Raven. Our former employee HÃ¥kan speaks in his blog entry from way back then about the enthusiasm we shared. Of course, HÃ¥kan speaks of our migration from Maven, the build tool from hell of which one should not speak.

So we’ve now gone full circle - Ant - Maven - Raven - Ant. So what happened and why?

Our build.xml used to be a trillion lines long and quite unmaintainable. When we first saw Maven we thought “Easy targets due to standard directory organization, automatic dependency downloads and we will probably read that really nice webpage thingy very often. Way cool, we want that”. Since we never have hesitated to throw new fun explosive stuff onto our e-learning fire we pushed all our directories around, picked up the ball and ran with it.

I looked at our old project.xml file today. Man, that thing is ugly. As Cedric points out, Maven is really four languages, and Jelly is one of them. Ouch.

At that time we were bitten by the Ruby bug due to a number of reasons, two of them being Jon, head chef of Damage Control who had just left us for new frontiers, and Anders Bengtsson who used to work for us but is still a good friend of some of the guys. This combined with our craving for a shiny new build system made us roll up our sleeves and start to build our own build system in Ruby, Raven.

When you start to build a new file system you most probably start with the easy pieces. “Let’s see … compile? That’s good - we need to compile in our projects. And we can set our classpath in a really non-obtrusive way. Oh, this feels so good, I’m glad we’re doing this. And next … Test? Awesome, we’ll be done in no time.”

… A little later …

“OK. it is not a good as in the beginning but we’ll refactor it. Now we just need to build the docbook docs, package the war, pack it up in a ear, zip that up with all external docs and whatnots and we’re done.”

Spoiler: The resulting build was as hard to maintain as the previous ones had been, albeit in a prettier syntax.

I believe it is exactly the same thing as when you start out with your Ant build file. As long as you’re setting up the compile and test part everything is really clean, but when you get into the specifics that is needed for your app like for example signing an applet - we used to do that - things get dirty. And it does not matter what language you do it in, it is complicated even in plain English, or Swedish. (”Take those files and sign them with that certificate file over there to produce an applet as a jar for Netscape, and when your done you take the same files and sign them again, but this time with that certificate file over there for Explorer, and, oh yeah, make it a CAB file. Don’t mess up or the browser barfs”)

While we were doing this, things happened in Ant land. Imports and Macrodefs solved a lot of problems, making build files readable. IDEA even provides code completion and refactoring support for Ant. As you might suspect, we did not have that for Raven. We slowly accepted fate and began the walk back into XML. However, among the brackets are a few goodies in addition to the ones above.

Ants platform independency is king. Visar, our designer guy, can run the app from his Windows box as well as we do on our Linux ones. I know, Ruby is supposed to be platform independent, but unfortunately it works in the same way Python does it - almost.

We have even rolled our own CruiseControl in Ruby. We really did not like CruiseControl two years ago so we might not use it now either, but at least now we have the choice. I’ve read a lot of good things about it recently and if it is good enough for Mike Clark it must be good enough for us as well.

To sum it up, Ant is a standard which in itself might not be the best thing at all, but with all the support for it it certainly comes out on top for us.

Functional Test Updated

Thursday, September 25th, 2003

After evaluating the previous named contenders for webtest tools, the winner was … none of them.

It dawned upon us that the MaxQ way of doing this, ie. recording tests, really is not the way to go, ever. What you’re really doing is testing the server from a HTTP perspective, without testing button clicking and stuff. For example, all hidden fields must be specified at every request. If you have anything Javascript based you still have no clue if this works after having these funtional tests.

On the other hand, using anything based on HttpUnit actually mimics a webbrowser, so you can click buttons and not have to worry about hidden fields. And yes, Javascript is handled.

jWebUnit is based on HttpUnit, but it has a rather limited API, for example you cannot find a button by its name to click it. We came to the conclusion that it was easier to build our own API on top of HttpUnit.

We also decided to implement the same API in a mock implementation ? la the way it is described in “Testing XP”. This way functional tests can be run very quickly on development machines and the more time consuming remote HTTP tests are done on the integration machines (Yes, we have several, one for every deployment OS).

Stockholm Syndrome and blameability

Friday, August 29th, 2003

Sometimes I get the feeling that a lot of people in programming suffer from some sort of developers Stockholm Syndrome. I mean, everybody whines about clueless management, we’re not allowed to do this and that, yadda-yadda whine-whine.

But then when presented with a option like Agile methodologies and XP which actually provides the power to decide about the things that should matter them as techies (because that is what XP is all about, you have the right to produce quality code given clear guidance under your own estimates and you go home by five etc), what happens? More whining.

It’s so comfy to blame clueless management for giving to little time, selecting a inferior platform and prioritize features over quality code. Many developers are simply not used to accepting full responsibility for their work. They’ve grown accustomed to the safetynet of blameability and need somebody else to take the responsibility if something should fail.

Kent Beck mentions courage as a essential factor for success. It is very true.

Time estimates

Thursday, February 27th, 2003

Joe is asking for ideas regarding time estimates.

First of all, read Planning Extreme Programming by Martin Fowler and Kent Beck. Even if you don't want to do XP it provides excellent ideas for planning.

The book promotes “the gummi bears principle” meaning that estimates should not translate to calendar time. Instead stories should be measured relatively to each other. So if story A is a 2 and story B is slightly harder, then it is a 3. This requires an upstart period where you “calibrate” your measures. But after a while you get quite good at it.

To really get away from calendar time thinking, we give stories “time points” which can be from 1 to 5. This helps developers to not think in terms if time, but instead sort of grading the stories.

At the end of each iteration, we sum up how many time points we did. This is our velocity and stories for the same amount of time points are planned for the next week.

It is by no means perfect, but better than any other technique I've tried.

XP, One Last Thing

Thursday, January 30th, 2003

I realized that after defending PP vigourously, it would be a good idea to second what Jon wrote about XP and the synergies of the practices. Which of course, Kent Beck stated already in the white book. (The XP'ers know what I'm talking about. To the rest, it's the first of the commie XP books.). PP is a part of a bigger, grander scheme, and seeing is believing. (Now, this might be mistaken for some Scientology offspring. One of the main differences is that you are allowed to read the books. :-)