After an hour or so of coding this morning, my pair and I had come to the end of the list of instructions we had been given for the Boris Bikes. Eager to push on and keep going, after a brief break for coffee we went and found one of the coaches and asked him what we should do next. His answer?
“Delete everything you’ve done up to now. And delete the instructions. Then start again”
A little shell-shocked and nervous, we went back to the little corner that we had claimed as our territory.
“But, delete EVERYTHING?”
we whispered to each other. That sounded a little…drastic. We knew that what we had coded wasn’t perfect. We couldn’t figure out how to make a Docking Station refuse a bike if it was full, for example. But deleting everything? That was a big step, and looking at each other, we both knew that it was a step we weren’t willing to take.
“What if we just kind of banned ourselves from looking at it and started from scratch on a new Git repository? How about we just spend a few minutes figuring out the short comings of our current code then come up with a list of things we’d want to change for the new code, and just start working with that in mind?”
So we sat there and played with the code. We tried to pinpoint every mistake we had made and discussed ways to improve them. It might have been the caffeine was slowly starting to kick in but we were both getting more and more excited. We could see what we wanted to change and we had ideas of how we could change it.
Could we include a scenario in which the person rented the bike and then broke it before returning it to the docking station? After lots of umming and ahhing, then typing in code, then deleting code and writing completely new code, we realised yes, yes we could. So why stop there?
Mapping out your journey
Trying to imagine the entire scenario in our heads, with all the different objects and interactions that were occurring was starting to get difficult, so we mapped it out. Suddenly, we could see who (or what) had interactions with each other, where these interactions fitted into the bigger picture, and how events or interactions could cause a cascading effect of the rest of the system.
Was it now magically easy and simple to rewrite all the code? Definitely not. We still had many times where we felt like we were banging our heads against the computer and getting nowhere. We started seeking the help of the senior cohort (who are now 6 weeks into their journeys of becoming programmers). Their help was indispensable and their constant encouragement got us through some frustrating moments.
By the end of the day we had not completed the code but we only left the building when we were convinced that we had a clear, concise set of instructions ready for us to get started on in the morning.
Lessons for the day;
- Map out exactly what you want your code to do. If you can’t see it in your mind’s eye, draw it out, write it out, act it out. Just make sure you know why you are writing what you are writing.
- Ask the seniors for help. Even if they don’t know the exact answer, they will be able to help you talk through it and come to a solution. Even if that doesn’t work, their enthusiasm and encouragement is contagious
- Take a break from sitting down and work at a standing desk occasionally. Your back, will thank you (yes, I am aware that back comfort seems to be a recurring theme…).
- Download ‘momentum‘ as an app for chrome. It will make your day brighter.