Dev Academy: Week 7 – Object-Oriented Design in Ruby

This week was focusing on Object Oriented Design. We had 5 challenges to do:

  1. Drawer Debugger
  2. Pez Dispenser
  3. Bingo Board Part Two
  4. Refactoring for Code Readability – on previous weeks challenge Validate a Credit Card Number
  5. Virus Predictor.

And I have just realised as I have started writing this post that Object Oriented Design hasn’t actually be explained to us. So, as I have been doing a lot in the last 7 weeks, I have googled what OOD is. Some definitions and links:

Object-oriented design is a programming paradigm that began in the late 60’s as software programs became more and more complex. The idea behind the approach was to build software systems by modeling them based on the real-world objects that they were trying to represent. For example, banking systems would likely contain customer objects, account objects, etc. Today, object-oriented design has been widely adopted by businesses around the world. When done properly, the approach leads to simpler, concrete, robust, flexible and modular software. When done badly, the results can be disastrous.

Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. Wikipedia,

It’s a process of planning a software system where objects will interact with each other to solve specific problems. The saying goes, “Proper Object oriented design makes a developer’s life easy, whereas bad design makes it a disaster.”

A link to a possibly useful book on the subject:

Practical Object-Oriented Design in Ruby (POODR) is a programmers tale about how to write object-oriented code.


Another book with an interesting title:

The Bastards Book of Ruby: A Programming Primer for Counting and Other Unconventional Tasks

Object-Oriented Concepts – A primer on object-oriented design and using it to organize your code.

In a nutshell, object-oriented programming sees the world as data, modeled in code by “objects.” In OOP, the programmer focuses on the content of that object and how that object behaves (i.e. methods).

So it’s worth becoming acquainted with OOP because it is a design pattern especially suited for programming with data. The practical benefit is that it can vastly reduce the amount of code you have to write and the number of errors of inconsistency to debug.

I guess I have a bit of an idea now and in the Treehouse tutorials we did make a bank account class, so can see the link to the first definition above. Do you have a good definition or explanation of what OOD is? And any good examples?

What have I learnt / done this week? Well, I feel more confident with writing methods, classes and how the methods interact with each other. I am starting to become more comfortable with breaking a problem down into more than one or two methods. I can see the relevance of doing this. I have learn about user stories:

… and used them in solving a problem and wrote some nice code, I think.

Screen Shot 2015-04-17 at 5.10.31 pm

Still not sure about what attr_reader, attr_writer and attr_accessor do, as it seems I can either have them in or not and my file still works?! For example in the above code having attr_accessor :flavours just above the initalize method, it will work. Anyone got a good explanation of what it a attr does and when it is used?? Perhaps I am just doing something fundamentally wrong in my code?

I have enjoyed solving the problems this week. Two were ones we did last week that we built on or refactored and the other three weren’t too difficult, although did do some work on the Virus Predictor challenge with another person from my cohort.

Another member of my cohort shared a link at this book – the (Poignant) Guide to Ruby –  and link to PDF. Even though this seems to have bee written by someone who is all over the place (the cartoons and long rambling paragraphs), the core part of the book explains what Ruby code is doing in a very simple way. For example:

Screen Shot 2015-04-17 at 5.52.32 pm

Two weeks left until the start of Phase 1 and the nine weeks of bootcamp. It will be coding from 9am till 6pm Monday to Friday plus probably lots of evenings and lots of weekends. I expect I will be very antisocial over this time. What will be good is that I will be based in at Enspiral Dev Academy in Cuba St and there will be lots of people around that I can get help from. Also, I hope I will be able to help some people as well, even though I have a big dose of the imposter syndrome – post on that shortly.

Ending question, what resources do you use, recommended for learning everything Ruby?


Dev Academy: Week 5 – Algorithms and Week 6 – Classes = lots of hard work!


Week 5 of Dev Academy was about building on what we covered in Week 4.

Last week you built up a toolkit of ruby methods. You practiced with them and gained a good intuition of how they work, what they’re used for, and so on. This week you’ll use that toolkit to solve some more complex problems.


This week also involved reflecting on each of the challenges and how you went. I found this part extremely useful. Over the week I worked on improving how I wrote pseudocode and actually taking more time to understand a problem instead of diving in quickly.

I am still at a point where once I get an idea in my head about how to solve a problem, I don’t take the time to think about other ways to solve it. This is something I need to work on – to improve my lateral thinking. I think as I become more confident in my understanding and use of code, my lateral thinking will improve. It is also something I will look to focus on in particular over the next couple of weeks.


In each of our challenges, once we solve it with an initial solution we then are asked to refactor it. I’m still doing this at a basic level (or at least what I think is a basic level). At the beginning of each week we get given examples of possible solutions to the previous weeks challenges, which proved interesting for the challenges in Week 5. I learnt a lot of cool things that you can do in Ruby to reduce down your code.

For example this loop:

Screen Shot 2015-04-12 at 5.06.19 pm

For if / else conditional statements, for this:

Screen Shot 2015-04-12 at 5.07.49 pm

And then you can ‘chain’ together lots of methods:

Screen Shot 2015-04-12 at 5.09.42 pm

So, this:

  • takes a number
  • converts it to a string
  • reverses it
  • turns it into an array of characters
  • splits the array into groupings of 3 (slices it)
  • turns it into an array
  • then maps it (copies it) to a new array while joining  the sub arrays together and putting a comma in between
  • then reversing it back.

Another challenge in Week 5 was the Accountability Group Creator!

In this challenge, you are going to make a method that takes an array of names (you’ll want to make a list from the people in your cohort) and outputs a list of accountability groups for three different units. You should try to get everyone into an accountability group of 4, but it’s your decision how to deal with cohorts not easily divisible by four.

This was a fun challenge to do but more importantly I could see the link to the possibility of making a product that I have used. While teaching Physical Education you need to split a class into teams. I discovered Team Shake, where you enter in your class list, how many teams you want or how many students in a team. You can also rank your students by ability level and then decide if you would like same ability teams or different ability teams.

2_IMG_4314 (1)

It was great to see how the Accountability Group Creator challenge links in with an actual app I have used.


Week 6 we started exploring Classes by firstly doing either the Treehouse Ruby Objects and Classes tutorials or Codecademy: Ruby (Object-Oriented Programming Pt. 1 and Pt. 2). I actually decided to do both and luckily they didn’t take ages and was worthwhile doing both as they covered things slightly differently.

We then got into challenges where we had to write classes! I found parts of this week quite hard and other parts not so difficult. The Bingo Board challenge I got really confused with and got myself all tied up in knots but some good learning came out of it for me. I used IRB (interactive ruby) really well to help me figure out what I was doing wrong, which I hadn’t done to this extent before. I have gotten better at understanding error messages, thats got to be handy in the future! With the Bakery Challenge I think I  finally got a good handle on hashes and how to access the values and keys separately.

I have also started using a visual diary and writing down code things so I can use as a reference over the next few months. There is no way I am going to be able to keep everything in my head!

The last two weeks have been really busy and full on (so much I didn’t do a blog post at the end of Week 5). Part of this was due to being sick at the start of Week 5 and during Week 6 I had a couple of days where I couldn’t do much coding. So, feeling pretty good with what I have been able to achieve over these two weeks.

Tomorrow begins the last unit of Phase 0. I think what we will be covering is Object Oriented Design, Databases, and Review. Three weeks until bootcamp!

Minion-220 (1)

Dev Academy: Week 4 – Hello Ruby!

This week was an introduction to the language of Ruby. Starting with the Ruby Basics course on Treehouse which covered:

  • How Ruby Works
  • Ruby Strings
  • Ruby Numbers
  • Ruby Methods

Screen Shot 2015-03-29 at 8.24.54 pm

Then into the Ruby Foundations course which covered:

  • Basics
  • Objects, Classes, and Variables
  • Strings
  • Numbers
  • Arrays
  • Hashes
  • Methods
  • Loops
  • Blocks
  • Procs & Lambdas
  • Modules
  • Core – core collection of classes and modules
  • Standard Library
  • Testing

I was pretty happy with all of the stages up to Blocks. Having completed the University of Canterbury Introduction to Programming course (Python) last year, the concepts and syntax is pretty similar. So, no surprises for the first half but then there was the rest! Blocks, procs, lambdas!?!?!?!?

I have an in-built need in my brain to complete all tasks/challenges when I am doing a course of study. So even though I haven’t really understand most of the last stages in Ruby Foundations, I had to finish them all. One day, hopefully, it will all make complete and utter sense to me.

We also had 20 exercises to complete this week from as simple as creating some variables to working out if a year had been a leap year, to creating a Factorial Method. I quite enjoyed doing these as I like figuring them out.

It was good to start getting into learning Ruby. What I am really looking forward to though is creating projects. I feel I can only go so far with making loops and finding strings in arrays. So, when I get to use Ruby to make something ‘cool’ I will be really excited!

Dev Academy : Week 3 – JavaScript and JQuery

I have really enjoyed learning more about JS and JQuery. I knew a tiny little bit. I think I understand more now, but definitely do not understand everything that I have gone through this week.

I had already completed the JS Basics and JS Loops, Arrays & Objects, so got on with JQuery Basics. Within this course the projects were:

  • Creating a Spoiler Revealer
  • Creating a Simple Lightbox
  • Creating a Mobile Drop Down Menu
  • Creating a Password Confirmation Form
  • Creating a Simple Drawing Application

It really works for me that the tutorials are focused on creating projects. I enjoy seeing how I can use what I am learning for myself, rather then just doing stuff for the sake of learning it (although you do have to do this at times when learning programming).

Besides working through the Treehouse tutorials, one of the suggested challenges for the week was to “Make your Website Interactive”. I liked the Lightbox idea and added this interactivity to my photo portfolio site.

Screen Shot 2015-03-22 at 5.37.40 pm

If you click on an image it should come up like this:

Screen Shot 2015-03-22 at 5.39.20 pm

If it doesn’t then you may have JavaScript turned off in your browser or your browser for some reason is blocking the loading of the JS.

I am also working changing the layout and structure of my personal website and am planning on adding a JQuery mobile dropdown menu. Although, you can create a dropdown menu using HTML/CSS and after I have had a go with JQuery I am going to look into doing it with HTML/CSS as I think it will look better!

The last project was creating a simple drawing application. I haven’t uploaded this, so just an image. Pretty fun making this and exciting to add the interactivity.

Screen Shot 2015-03-21 at 5.31.27 pm

Another suggested challenge was the Treehouse course “Interactive Web Pages with Javascript”. This is creating interactivity just using JS and no JQuery and using the DOM! I am into the third stage which is “Traversing and Manipulating the DOM with JavaScript”. It is taking quite a lot of my brain power and I know I won’t have grasped everything by the end but it is a start.

I have started early on Unit 2: Ruby Fundamentals, Week 4: Ruby Basics as I have work all week and am not to sure how much time I will have in the evenings. It is going well so far and I was also able to fix some Ruby stuff in my terminal so I could run the tests for the exercises. So all round quite a productive day. And I got a surf in this morning!

More on Ruby Fundamentals soon…

Intro to Programming – Treehouse

Have just completed the short block ‘Introduction to Programming’ in the Front End Web Development Track on Treehouse. Enjoyed doing this. Learnt about using the console in Google Chrome and then creating a JS file and running through Chrome and seeing results in the console for the page.

This was a short course but worthwhile doing even with having done some programming before. It was good have a recap and of course learning how things are done in Javascript, as the only other language I know a bit of is Python.

I have been pleased to learn that I have retained quite a bit about the concepts of programming from the Canterbury University Intro to Programming paper I did over the first half of 2014. And more importantly I think, is that I am confident to try out things and search for help when I am stick, rather then just thinking I can’t do it. Had a couple of these moments when working through this block.

Screen Shot 2015-02-11 at 5.01.34 pm

Changing of content – had just finished this Introduction to Programming and went back to the Front End Web Development page to have a pop up saying that changes had been made to the course. You have an opportunity to review the changes before updating to it, which is good. I decided to update, as I kind of think that an update would be an improvement plus it affected mostly blocks I hadn’t done yet, except for the Intro to Programming. Which is now JavaScript Basics and some stuff added later on as well. So now onto JavaScript Basics – I may fly through it!

Preparing for Enspiral Dev Academy

This year I am on a journey to learn to code – like really learn to code. I have taken leave from school and have enrolled in the Enspiral Dev Academy.



Just before Christmas I got an email from them about starting the pre Phase 0 prep, so I have started looking into what will be best for me.

I started with learning some basic HTML/CSS when I started teaching unit standards at Level 2 back in 2010. Using tables to do  page layouts (rather ugly and hard to work with), to in 2014 learning more about CSS, elements, divs (with it also being the second year of teaching achievement standards at Level 2!).

In 2014 I had quite a step up in my coding/programming experience. In March I attend the RailsGirls Wellington weekend, which was an explosion of coolness. Due to the requirement at school to teach programming in our Level 2 course, I also completed, in the first semester, the Introduction to Programming (Python) via the University of Canterbury. Made myself a bit sick doing this but completed it and rather happy with how will I did.

Once I started exploring the idea of doing the Dev Academy seriously I started doing some stuff on Codecademy. I preferred doing the HTML/CSS course rather then the ‘Make a website’ option as it made more sense to me doing stuff in order. I also started on the Javascript course. I found it a bit tendency and basic in what the content was but this was maybe due to having a good base already.

I than started having a play with the HTML/CSS Code Avengers course. Again, I started at the beginning and found the interactive layout more suited to me then Codecademy. I like it because it outlines when you start what everything is and where to find help. It gives hints in the tasks and output examples of what you are creating. I found all of these useful when I got stuck at particular points. As I went through the Level 1 course, even though I knew most of the stuff that it covered, there were a few little things that I picked up that I thought would be useful. It also outlined industry standards or expectations.

In December 2014 I attended the Computer Science 4 High Schools conference in Christchurch, run by the Computer Science department at the University of Canterbury, led by Prof Tim Bell. During this I was able to attend a few workshops, one of which was with Mike Walmsley, the creator of Code Avengers. We did some stuff with Game Development in Javascript (which can be used for NCEA Level 1/2/3 programming) and did a fun challenge with JS. I can imagine that the camps they run would be pretty cool. The game development was cool as well, as you could deploy it and send out the link (see previous post on CS4HS).

The other workshop that I attended was run by Tanya Gray from Gather Workshops – jQuery Taster: Enhancing Websites with jQuery. I found this lots of fun. As the information was online I was able to go a bit ahead as there were different levels of experience in the room. I found this really useful. It was a lot to get done in a couple of hours but doable. It was exciting to add some cool stuff to a site – here is my attempt.

With both of these workshops, even though they were great fun because of the interactivity, it would take me a lot of time to create something similar by myself, as I don’t yet feel I have the knowledge OR understanding of how it all works to be able to create something from scratch. This is the gap in my own experience/knowledge that I want to fill.

I have also had a look at CodeSmashers. This is a new start up that is looking to fill a gap in helping people learn to create their own websites. They use HTML/CSS with a bootstrap framework and by the end of a weekend you can come out with a cool looking site. You may not have a complete understanding of how and why it works the way it does but it is a pretty cool start and there is also an online platform for help from the tutors as well as other participants from your course and all the other courses that CodeSmashers have run. It will be exciting to see where they go next.

Another online course I have access to is Yoobee’s HTML AND CSS BEYOND THE BASICS. I have found this useful in thinking about how I want my site to look as the first task is going a mock up. However, they use a lot of videos and don’t have an online coding area. So the tasks you compete in a text editor then you upload what you have done to a forum and get feedback. By the end of it I should have a good looking site and hopefully learnt new stuff.

Now, back to the email from EDA for the pre Phase 0 prep and where to from here. They have recommended a few sites:

I have done both the Try Ruby (which was okay but a bit strange in how it worked) and Try Git (loved this, the way this was layout and worked was great for me!).

So, the question is where should I go to from here? Have I done enough in HTML/CSS? Should I jump into Ruby or JS first? Which resource should I go for? Should I go back to Codecademy or Code Avengers and start some of their courses further along and skip the basic parts?

What online training have you done? Do you have any recommendations or advice?

(This post is hopefully the first in a few. Planning on updating about online resources I have used once I have completed the prep phase).

Next-level Web Design with jQuery – #cs4hschch

This session is a taster for interactive web development using jQuery. An understanding of HTML and CSS is required, but no experience with JavaScript or programming is necessary. Learn how to easily add a slideshow to your website, create an interactive image gallery, and dynamically load a set of images from Flickr. If you’ve ever wondered how jQuery and JavaScript fit into web design, this session is for you. The tools used are all freely available for use in your classroom.


What is jQuery?

  • It is a JavaScript library
  • Adds interactivity to websites
  • DOM manipulation (DOM = Document Object Model) – the structure of objects on your webpage

A web page is made of three main languages – HTML / CSS / JS. Good example using showing HTML only page, then with CSS then JS.

Workshop Mission: Fun with jQuery

Neocities: Getting online fast

jQuery Basics

What is this thing anyway?

jQuery vs JavaScript
  • JavaScript is a programming language.
  • jQuery is a library of code which is written in JavaScript.
Handwritten jQuery
  • Can be used to modify a single element
  • Or to modify a whole lot of elements in the same way
jQuery Plugins
  • A plugin is a pre-written piece of functionality.
  • Plugins need to be included in your site and then initialised.

Workshop Plan

  • Use a plugin to create a slideshow
  • Use a plugin to create an image gallery
  • Write some code to import images from Flickr
  • Allows you to add a dynamically-resized, slideshow-capable background image to any page or element.


  • Popup image gallery
  • Provides a simple way to create a gallery with both thumbnails and full-view images.

Flickr Integration

  • Pulling in themed images
  • Flickr Public API
    Flickr provides a way to search their images from code.
  • This means we can get a list of information about a set of images automatically.
  • The API we will be using is the public feed found here.
  • API = Application Programme Interface (a way to get data in and out of an application)


  • Many APIs offered by web applications use JSON as a way of transferring data.
  • (JavaScript object notation)

My site –