Yesterday I finished the Codebreaker example in the RSpec book. I spent many hours in a confused state, and then it began to make sense. The book teaches you to follow a red/green/refactor cycle when building tests and code.
Yesterday, I was in the green as far as my understanding went, so I decided to apply that knowledge to my own existing code. Now, I'm back in the red and pretty confused.
This is what my day looked like:
1. Red (go back to the book, beg Google for answers, try something, try something else)
2. Green (something actually worked, sweet),
3. Refactor (try to do something mildly snazzy),
4. And back to red. I spent most of the day in this part of the cycle.
I do like the principles of BDD and the theory behind what I'm learning, even if the practice itself is a bit challenging. It makes sense that one would want to write self-documenting code and build tests that also serve as documentation.
As I work through the exercises, I keep thinking back to web projects that I've worked on the past, and how this process would have made a world of difference if it had been followed by my team from Day 1. This methodology really speaks to my sense of organization, but given how long it took me to work through the first example in the book, I can't say that it speaks to my sense of efficiency (yet). I'm hoping that perspective will change as I become more comfortable with RSpec and Cucumber.
No comments:
Post a Comment