Skip to content

The Code You Want

In reading the excellent RSpec Book, I came across a great idea that I’ve been using as my mantra of late: “write the code you want to have.”  In its original context, the authors discuss how to write your test scenarios when you have not yet implemented the code behind them.  In that case, they suggest you code to an imaginary world where you use all the wonderful methods and accessors that would make your life simple.  Then, you go and implement those wonderful methods and accessors.

I think it’s also useful at another, more philosophical level, however; sometimes we don’t write the code we want because we perceive it to be too difficult to write.  Or we don’t work in a language because someone says it won’t work, or we won’t be allowed to deploy it.  In these cases, writing the code we want to have becomes more of a rallying cry in order to Get Shit Done.  I need to make some kind of cross stitch sampler to hang on my wall with that thing.

Write the code you want to have.

Post a Comment

Your email is never published nor shared. Required fields are marked *