Categories
Development

Setting up testdata with test data builders

Doing TDD has become a way of life for me. One the one hand tests are the security net that lets me refactor my code, but is also a restricting force when it comes to changing code. Experience has showed that when I refactor, I also break a lot of tests that’s not relevant for the thing that has been changed. And the reason for this is usually set up of test data that has been scattered through my tests.

It’s not that setting up test data is that difficult, but unless you are structured and focus on not duplicating setup you will get into a mess. I found this interesting article at DZone describing a technique called Test Data Builders. Interesting idea I need to check out.

Categories
Development

Ruby with Maven and a bit of Cucumber love

A while back I was trying to do some initial tries at Ruby as a scripting language with JRuby. That means that I had a Java system, but needed to do some util scripting for the system, and wanted to avoid those pesky bash scripts. Because I had a Java system and Maven infrastructure in place I really wanted it all to work nicely with that. But the whole Ruby and gem ecosystem threw me a bit off. Long story short: I never quite figured out how to do that and had to move on getting things done.

Madaspeak has a nice post showing how you can run Cucumber in Maven as tests for your Java classes. Cucumber is an interesting BDD framework from Aslak Hellesøy, and in the process you can also learn how to enable running of JRuby in Maven.

Categories
Development

Redesign is not going to save you

This was really a ReTweet from Johannes, but my mind started working and it got sort of out of hand for a tweet. 😉 Both his comment and link was excellent:

Software tends towards more technical debt. Without the discipline to reverse this, we won’t succeed in a rewrite either. – Johannes Brodwall

The article that he linked to is the “The Big Redesign In The Sky” from Uncle Bob. If you understand Norwegian also check out Karianne Berg’s really good lightning talk on the subject.

I myself really have to fight the urge to start over on a green field application. I know it takes too much time, and the result will be much worse than what I hope for when I start out. But what it really comes down to is wether you have the mechanisms in place that lets you incrementally improve your application. Without confidence in the changes made developers will avoid doing them, and your application will continue to rot. So what can you do to encourage changes? Some of my personal favourites:

  • Unit tests
  • Functional tests
  • Web tests
  • Database tests and migrations

All of these can also resist change if done badly, but you need to start somewhere. It’s really hard, but finding a path for incremental improvement is the best way.