The past couple of days I’ve been continuing to work on integrating a Repository using DataMapper objects and a PostgreSQL database. Last week I came off vacation feeling really good about how I’d set up my abstractions for my in-memort objects and their datastores, and I estimated that at the longest it would only take me a day and a half to wire up the new Repository.

That was dumb. My first mistake was that I was probably just too damn optimistic coming off of the break. I’d taken a proper vacation and spent very little time with the project code, and I also hadn’t thought about DataMapper for a few weeks since I’d been using in-memory objects. I should have checked myself on three counts:

1) I’ve never used DataMapper in-depth before and whenever using a new technology I should always give myself a buffer.

2) I was using a “sort-of” repository pattern, but to properly implement I needed to deepen my understanding of it. I’m very lucky that Paul and Doug are concurrently implementing the Repository pattern on an internal project so I have some excellent code to use as an example— but reading through that code is still additional time.

3) In order to avoid duplication and ensure that my in-memory and DataMapper objects were interchangeable I wanted to use RSpec’s shared examples, which is something else that I’d never used before. Technically, setting up shared examples is relatively easy, but refactoring the test set-up so that all of the shared examples can use the same variables is another lesson in abstraction… and again takes more time.

The good news is that things are moving along now and I’m learning a lot. In a couple of my class_specs I’ve even been able to just copy and paste the specs into shared examples and it has quickly test-driven my way to new DataMapper objects and repositories. The bad news is that if this was a client project I’d be working well into the night to complete this story so that I could also finish the other points I’d committed to for this iteration.

My other takeaway from this experience is just how important a team is. If I’d been working on a client project I (hopefully) would have been a part of a team that would have added some additional knowledge and perspective when it came to the estimate. Someone on the team either would have recognized that we were using a new technology (and needed to give ourselves more time), or would have been familiar enough with the technology that we could have cruised through all the little snafus that ended up being valuable “lessons” for me, but also ate up valuable time.