Stuff about software development, agile and testing

Tuesday, October 23, 2007

hudson rules

Gone those days when we were promised that copying a war file to web server will bring your application. I thought that's a myth in Java world(what happened to webstart anayway?). But when I looked into Hudson today my eyes were wide open, its possible..all j2ee developers out there close your xml editors and take a pick.

We use Anthill Pro for our continuous integration build and it has all the bells and whistles you expect from big CI tool these days. But Hudson has only those basic things that you need to setup a continuous build environment. I was able to setup within 15 mins using my existing ant build file. Now when I compare with other tools they seemed to be over-engineered and difficult to setup and use(Let me know if I am wrong). Did I mention it has some cool plugins.

Wednesday, September 12, 2007

ejb 3

After ranting about Xml and j2ee development pain, I have to agree that ejb3 is really awesome. I was able to develop an entity and session bean without any deployment descriptor apart from persistence.xml file. Its really cool to see power of annotations in practice. Having a reflection of field experience really helps any framework to be more developer friendly.

Friday, September 7, 2007

xml bites again

Have you seen anybody who actually like doing j2ee/xml work?

I haven't and just because 90% of java work is j2ee stuff they are tied to it in spite of the dislike. If you have noko niko calendar of your team all you will see is :( . Apparently it took 1 day for me to integrate one external ejb with our module. I don't consider myself a j2ee expert but honestly how good are collection of xml configurations when every time you change something you have to redeploy. All I want is to compile and run my tests, is it too much to ask? . If you have a big project like us then you are screwed because every XML change requires jaring, redeploy and restart of your application. Its quite a big cycle when you have no compiler watching for your deployment descriptor errors. I am not sure whether Websphere application developer or Weblogic workshop have any sophisticated logic to validate your DD's before even deploying it.
Anyways do we really need all these descriptors to deploy some manage beans? Introspection and clever defaults could solve all the problem and it doesn't need a CS degree to figure that out, maybe some practical experience.
Honestly have anyone used any 3rd party ejb components or followed all the j2ee roles? If Java at all wants to make a component market a reality make it easy for developers.

Thursday, September 6, 2007

Fluent Interface

Like most other projects out there we are using fit/fitnesse to write our acceptance tests. But to be honest I am not very big fan of fitnesse. It doesn't scale very well with project size and having fixture tables through out fitnesse pages doesn't help readability and maintainability.

Especially if you are building web application you leave the UI part out of the test unless you integrate your UI test tool like selenium with fitnesse but you still miss the readability for tabular test structures. When we get story in BDD(Behaviour driven development) format and acceptance criteria in Given-Then-When style I expect to see my test in following pattern.

"Given products exists when I search product by name then user expect to see all matching products" do

test "goto product page and search for product code '100'
now number of matching products found is '10' "

end

Doing something like this Ruby is possible and in fact Dust is doing something very similar. But achieving something like this in Java is a challenge. Fluent Interface is one of the easiest way to do achieve DSL like look in Java and its quite easy to implement too. Lets consider the following selenium unit test

public void testGivenProductsExistsWhenISearchProductByNameThenUserExpectToSeeAllMatchingProducts() {

goToProductPage().andSearchForProductCode("100);
assertThat(now().numberOfMatchingProductsFoundIs("10"));
}


Its not cool as ruby DSL's but its close and quite readable. Some of our test now looks like this and rest of the team loves it.

Sunday, August 26, 2007

Five different ways to test equality

It's bit confusing when it comes to test equality of objects in Ruby. It has five different ways to do it and each one has a different purpose and context in which it should be used.

equal? returns true if receiver and the parameter object have same object_id. Object ids are unique and its not shared among the objects. This method should not be overridden

== returns true if the receiver and parameter object has same values. This is most intuitive and should be overridden in your sub-classes

eq? Like == it compares objects but is more strict about type. Only reason this exists is to compare Hash keys

=== This is used for Switch Case statement. It compares target in case statement with each selectors. You can override it to control the way case statements are matched inside the switch block

=~ Pattern matching (Side note: In Erlang = does the pattern matching)

== and =~ does have a negated version and since ruby is a great language if you implement == you != for free, isn't that great.

Next time when you have to equate objects you know which one to use

Tuesday, August 21, 2007

Ruby open classes

This issue have been flamed in many blogs and Java programmers are not very comfortable with open classes that includes me. But its really powerful there is not doubt about it, like Neal ford said how many times did we created StringUtils class in our java project. But I guess re-opened classes should be organized in some way where everyone knows where to find it. When I say "1.hour.from_now" example in the rails book for the first time. I was really shocked, does it makes sense to have hour method in Fixnum and to add more confusion if you open irb and look at fixnum methods you will not see it at all.

One of the thing that Java programmers should get over is you cannot know a class in Ruby completely. In Java we could say that I know the String class, I know how many methods are there and what are those methods etc but in the world of open classes you never know. There is no replacement of communications, in ruby world its more important talk about your work with other teammates and unit testing of course.

Tuesday, August 14, 2007

netbeans ruby support


If you are used to eclipse or intellij, you know how hard is to live without auto-completion, debugging and refactoring. Textmate is cool and simple but netbeans ruby support is probably best right now. It actually uses string pattern matching to list out all the options and its pretty fast. To download ruby only version go to link

Labels