Here at Pivotal Labs, the engineers practice Extreme Programming, which means our teams write automated tests, we do pair programming, and we continuously refactor.
In the past, I’ve been overly eager to refactor. I have had:
- several refactorings in progress at once
- interrupted my pair to refactor something only slightly related to our task
Recently, I’ve started keeping track of my clean-up wish-list as my pair and I work through a story. Since is it is easy to get lost when refactoring under red tests, once we are green, I discuss my ideas with my pair. Maybe we tackle the clean-up task then, maybe we tackle it before we push to Github, or maybe we discard the idea. We work through the list one-by-one, maintaining a green build. We check in our work before we start an item, and then each item gets checked in as well, so we’re always able to back out of a refactor gone bad. Maybe my pair thinks of some other things to add to the list. I find that we finish our stories quicker, which allows us some extra time to squash some minor code smells and move on to the next story.
I like to use 8.5×11 paper, folded in half once. This gives me plenty of room to keep track of my items, while also giving me plenty of space to draw diagrams to explain my ideas or note tests that I’d like to add. I find that one piece of paper usually lasts through one story and then I start with a fresh sheet for the next story.
Do you have productivity hacks for improving your pairing session? I’d love to hear about them.
About the Author
More Content by Adam Berlin