Nov 13

Rubber Duck Debugging

This is an edited version of the last of 3 blog posts, previously blogged on ‘Austen, Morgan and Me

In the second week of the Coursera R Programming course and things were getting decidedly tough with the focus being on creating functions. The shift from basic calculations to writing functions is a very steep learning curve.

I had made the mistake of reading a ‘warning’ post which highlighted the difficulties of creating the assignment functions, but also linked to some very useful materials (some of which I had already studied). Initially, this post made me panic as it emphasised the number of people who dropped out of the MOOC as well as the fact that the number of hours required were optimistic, even for a skilled programmer.

As seems to be my default at the moment, I talked this problem through with the dog during our afternoon walk, she is a fantastic listener! I asked her how I would have felt if I hadn’t read the post? I wouldn’t have been worried. What would I do if/when I got stuck? Use the message boards and the internet to solve the problems. So, aside from completing the very helpful tutorial, I decided to act as though I had not read the post. [Having completed the CS620c Structured Programming Course in Java, I have found out that programmers call this ‘Rubber Duck Debugging’!]

The assignment for the course had 3 parts and a function to be written for each. The first part took a while, not as long as I had feared though, and the message boards came to my rescue with a final issue I needed to solve.

The second part of the assignment was actually a bit easier as it built on the first, and I was feeling a bit more confident having completed the first task. Again, my sticking point was one aspect, I asked for help on the boards and tried some solutions, to no avail. So, I decided to sleep on it and go back to the start. I rewrote the function line by line, testing as I went and adding markdown comments. This time it came together much better and I had only a fairly simple tweak (which only took 3 trials to get right) before it was ready for submission. I have to say I was very pleased with myself.

The final part was somewhat tricky. I managed to get myself to a position where a correlation was being returned, but only a single result rather than multiples. I felt like I was going round in circles, tweaking the code and retrying it. It turned out that the problem was with my subsetting. When I printed my code it looked like everything was finally starting to work, but when I ran the example outputs it came back as NULL! A few moments of panic before I realised that I had simply forgotten to return the result within the function. So, finally the assignment was completed and submitted.

I think this also goes to show the importance of mindset when approaching difficult tasks. As my background is literature/history and Education, I haven’t really had a great deal of experience using maths and computing. I know I can learn things, like many people who grew up in the 1980s, most of my computer skills are self-taught, but it is that nagging voice that puts me off, causing doubt to creep in. Well, quite frankly, it can get lost!

1,947 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>