A couple of
weeks ago, during a code retreat, I was pairing up to start a new coding
session. As I wanted to write the first
test, my partner said that I should avoid the word ‘should’ in my test names. I kindly nodded my head but the first thought
that crossed my mind was: here we go again. As it appears, the word ‘should’ implies that
my test might do something without
any certainty that it will do
something… Granted, it’s not wrong what I was told, still I was wondering: how
much time and sometimes even money are developers wasting participating in these
kind of über developer sensei discussions?
Don’t get
me wrong, I find discussions about code intriguing and I love learning from my
fellow developers. But… aren’t we
sometimes pushing these kind of discussions into the ridicules? An industry as infantile
as ours (not necessarily by age) should be worrying about larger problems.
It seems
kind of trivial that this gets me going, but just think about how many times
developers are wasting time and are overengineering their code because of silly
discussions like these.
For
example, take the one assert per test rule.
How many evangelistic developers have I seen taking this rule to the extreme. Testing a simple 1 on 1 mapper
property by property. And for what
reason? Because there is a golden rule
that tells you that you must do this or you're not writing clean code? Why not be more pragmatic? In many cases you
have a beautiful set of testing tools! Use them to send messages to your test
runner. Extend your tools to make life
easier.
Extremism
can be a good thing to! Take Robert C. Martin, he’s one of my favorite speakers
and is my favorite writer. Yet, he is
the Osama Bin Laden of clean code. I can’t
imagine anyone taking it more to the extreme than him. In his case, good! We need magnets like these
pulling developers away from the dark side of procedural spaghetti code. Just as long as these developers still have a
mind of their own, and know that the only golden rule is that there isn’t a
golden rule.
Strive for
Perfection, Settle for Excellence.
Geen opmerkingen:
Een reactie posten