Categories
Development

DDD and generic repositories

Reuse is good. That’s what we learn, so we all strive to reuse code, but sadly sometimes we over generalize and try to be too clever. I have had the suspicion that creating generic repositories that takes criteria/queries as input parameters is one such over generalization. Some things, in fact a lot of things, are worth making explicit.

As Greg Young points out in this excellent article, this over generalization can even hurt you when it comes to tackling performance at a later stage. It’s well worth the read. 🙂

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.