KISS & Click
For the first part of this week I felt like I had my head down and smoke billowing out my ears as the gears in my head struggled to connect. I had a good idea of what I had to do with my tic-tac-toe app, but most of my attempts at doing it led me to pages full of scribbles and windows full of browser tabs as I tried to figure out how to do it. I just wanted to pass a method two arguments: which player was making the move and what the position of the move was. However, in my reading of Clean Code I knew that you usually wanted to pass as few methods as possible (one being the ideal number), and in order to actually place the move with the correct symbol for that player I would also end up breaking the Single Responsibility Principle, the Open Closed Principle and possibly even the Dependency Inversion Principle.
But then Mike came over and asked the right question— why not just break it up into two separate methods? Doh! Of course, and that lead to the bigger lesson this week. Something that I’d experienced at Code Academy but had fallen out of the habit of doing. As soon as I started to feel that tension in the code with what I was trying to do I need to take a deep breath and apply the KISS method: Keep It Simple Stupid.
Of course KISS is not exclusive to programming, but just generally good advice. I first heard of it when I started managing cycling teams and events. I worked with a Board of Directors that had two mottos: KISS and “a camel is a horse designed by committee” (meaning that if an idea started to lose it’s shape we’d defer to the person who was most passionate about execution. It was a fun BoD to work with, but that’s a whole other story).
With KISS in mind a vision of tic-tac-toe adhering to the SOLID principles started to fall into place. Somewhere between 3pm and 4pm and the right and left headphone there was an audible click in my brain. I’m sure it’s not the perfect solution, but as I sketched it out (I draw or write out a lot of ideas before I code them) I could point at specific examples of where I was following certain principles.
This morning I’ll spend a little bit of time test driving my code for the app, but I’ll also start working on my first kata and every Friday there’s usually an 8th Light University here too. Today Jeff Cohen is coming into talk about teaching beginners at Code Academy. It will be great to see him and some of the other alumni.