May 2012 Archives

What Moose is doing to my nose

It's only been a couple of months since I've been using Moose, but it is already changing the way I read code. Of course, it changed the way I write code in a very short time, but I was surprised when I realized that it also changes the way I smell code.

Things that seemed normal last year, now are a code smell to me. Whenever I see an object being constructed inside a method whose name doesn't start with '_build_', I wonder if something bad is going on. Even method calls with parameters are now becoming a code smell. Whenever I smell that smell, I ask myself "should this be an attribute?".

And that's a pretty good thing. I never found testing my code easier. "Dependency injection" is harder to spell out than it is to just do it. And I find myself being able to understand my own code a couple of weeks later.

So, to sum it all up: Thank you, Moose Cabal!

About confuseAcat

user-pic Random observations that may in some way be related to Perl.