Reflections on the third week of the Makers pre-course

I did not have a huge amount of set work to complete this week: three more chapters (and quizzes) from the Ruby mastery curriculum, on hashes, methods, and classes respectively. I’m reasonably confident with the basics of methods and classes, but hashes have always slightly baffled me, and they were what I started the week with. In particular, my sluggish Monday morning brain had to grapple with grouping arrays of hashes into new hashes with specific key-value pairs — this was quite confusing at first, but I persevered and eventually figured it out by working through the exercises with a REPL (I find that going through coding exercises — no matter how simple — stage-by-stage with a REPL is a really useful way to figure out what Ruby is doing). The quizzes were not too bad: using a hash to generate word scores in Scrabble was pretty straightforward, but grouping an array of hashes into people based on their favourite sports or fruits was more taxing but, again, not insurmountable when each quiz was broken down into steps. I was pleased to have completed this chapter by lunchtime on Monday, and felt a bit more confident about using hashes in future programs.

On Monday evening I attended an online meeting of the London Ruby User Group. I felt quite out of my depth during the talks but enjoyed them nonetheless. It was interesting to get a sense of the problems and types of project that people are undertaking with Ruby in ‘real world’ contexts. I was also encouraged by one of the speakers — Rob Faldo — who is a Makers alumnus. You can read about the content of his talk here.

On Tuesday I tackled methods in the penultimate chapter of the mastery curriculum. I’ve written a lot of Ruby methods for Codewars katas, but quickly realised that I haven’t actually spent much time ‘joining’ methods together. Luckily, the quiz gave me a good opportunity to practice: I had to write a specific number of named methods to complete a simple Blackjack game. I struggled a little bit with this exercise — while the code was not particularly complex, I had to think quite carefully about return values and what parameters each method would take. I also found it quite difficult to break out of an infinite loop: I used recursion for bits of the game loop, and certain inputs in the RSpec test would cause the classic ‘stack level too deep’ error. It only took a tiny modification to my code to sort this out, but it took a fair bit of thinking before I got there!

The final part of the mastery curriculum, on classes, didn’t pose as many problems as the methods chapter and quiz. Using a REPL to get ‘under the hood’ of what my class instance methods were doing, and how they were interacting with each other, proved an effective way to complete the quiz, while my experience of classes from Exercism was also useful. The final quiz looked like a real challenge, but the solution was deceptively simple. Once my answer had passed RSpec, this meant that I’d completed my week’s work by Wednesday — what to do next?

The Blackjack exercise had sparked a memory of an earlier programming experience (and by earlier, I mean over thirty years…) and I spent a few hours on Wednesday and Thursday converting a 1980s BASIC program into Ruby, and then trying to make it ‘more Ruby’. This involved some good practice with methods, classes, and various Ruby commands. I also used Rubocop to correct coding ‘offences’. My blog about this little project is here. Part of me felt that this was maybe a bit of a waste of time — maybe I should be reading more about Ruby? — but I also felt it was a good exercise to write and refactor a program while figuring out bugs. It was also a nice link between my first experiences programming computers as a child, and my present-day ambition to learn how to code.

Looking back on the mastery curriculum, while I found it mostly straightforward I do think some of my programs could have been more ‘efficient’, though at the same time I was always trying to limit my code to what we had been taught up to that point and not use more complex commands.

On our cohort’s Slack channel, a number of people left messages this week asking for help when a particular quiz was proving problematic. I spent some time offering advice and tips, but deliberately avoiding giving the answer away. I think my previous life as a university teacher comes in useful in this regard!

As well as doing the daily Codewars katas, I also had a pair programming session with Graeme from my cohort on Thursday, and with Dan on Friday. I fell back into bad habits with Graeme: when I was in the driving seat I became a bit over-absorbed in creating (what turned out to be) an over-complex solution to my kata, and I ‘lost’ my navigator. It is really easy when programming to ‘run’ with an idea, but it is still important to break it down, step-by-step, especially if you are trying to explain what you are doing to somebody. The following day I was better at explaining my solution to Dan, albeit it was a very easy kata. Dan’s problem was more complex (the kata is here) and we worked well together to come up with code that worked in theory — but which unfortunately timed out on some of the tests. With our allotted hour nearly up, we agreed to go away and work on the kata individually — this is how I learned the Ruby lcm method!

Overall, this was probably the most ‘relaxed’ week of the pre-course so far, with no technical hitches or major difficulties. I continued to learn what I need to improve, or practice further, and it was nice to make contact with more members of the cohort. The final week of the pre-course looms and, after that, I’m expecting not many more ‘relaxed’ weeks as the bootcamp begins…

Learning to code at Makers Academy