Wednesday, January 21, 2009

Announce: Conventionally Scoped Names Gem

I've posted a conventionally_scoped_names gem to github.

More info:


My main motivation for releasing the code in gem format was for the experience (never having done it before). And who knows? It might prove useful to someone.

Two things I learned:

  1. it was not quite as easy as I had expected

  2. artificial constraints really slow things down

Point #1 is an important one. I had expected obstacles, just not some of the obstacles that I met. Honestly, that's not 100% accurate. I expected obstacles, but envisioned being able to blow through them with ease. I made it through, but not with the ease I would have liked.

As for point #2, I can sum it up like this: sometimes I'm obstinate to the point of dumb-assitude.

I normally use RSpec for testing and follow TATFT. For this gem, I decided that I needed to follow the Rails testing convention more closely. At the same time (and this is where the obstinate bit comes in) I refuse to use Shoulda, Context, and Mocha, because, really, what do they give you that RSpec does not?

Thus, my artificial constraints were that I wanted to write tests for a controller/model plugin without being able to mock easily. That meant fixtures, which are not my bag, baby.

My biggest problems were with the fixture datetimes. For whatever reason, I could not get date comparisons to work properly with the in-memory sqlite3 DB. Eventually, I opted to use string dates instead of datetimes (it did not affect what was being tested one way or the other), but I spent a lot of time trying to get it working.

I could draw the lesson from this experience that if I do not impose artificial constraints, I will get done much faster. But you know what? There are always constraints—artificial or otherwise. To be a better coder, to improve at my craft, I need to get better at meeting and overcoming constraints.

So what I choose to take from this experience is that I need to keep up the reps.

No comments:

Post a Comment