Dev Academy Bootcamp: Wk 2 — OOP

Dev Academy Bootcamp: Phase 1 – Week 2 — Object Oriented Programming

The focus of this week has been Object Oriented Programming.

During this week I have learnt:

  • a lot about classes and fruit trees! (The first activity was creating an Orange Tree Grove and then converting it into a Tree Grove with different types of fruit trees – enough said.)
  • introduction to test driven development
  • inheritance
  • encapsulation
  • coupling
  • law of Demeter
  • private / public
  • user stories
  • MVP – minimum viable product
  • made cookies and ovens (no, not in the real sense)
  • parsing data
  • MVC – model view controller
  • working with others

Wednesday evening our homework was to watch a video on Models, Views and Controllers, to set us up for Thursdays challenges on MVC. We had built a Flashcards console app the day before and on Thursday we had to change it so that it was suing MVC design pattern. I enjoyed this and using classes really started to make sense to me.

It has been good to get to a point where we are making things that do stuff – actually making a flashcard app (even if extremely basic and only in the console) compared with making orange trees, cookies and hospitals.

This image really helped me understand MVC the flow of how it all works. mvc-sequence

After completing our Flashcard challenge and making it follow the MVC pattern I was feeling pretty good leading into our first group project on Friday.

I wasn’t too sure what to expect except that we would be working as a team of four Rubyists and building something to do with what we had been learning over the first two weeks. The project was pretty open, we could decide what we wanted to build, obviously though, a console run program was used, as thats all we know so far.

Our group of four has probably focused more on our group processes over the last two weeks then the technical aspects of coding. I have enjoyed this as I have learnt a lot already about working with others in the environment. I feel that this meant that we had a strong base as a group to work from with our project. We took our time with planning out what, when and how we were going to do things. Although we may  possibly have gotten bogged down in choosing a product/idea to make if one of the teacher aides hadn’t come over and given some thoughts and suggestions.

A side note – I am really appreciating the way that the teachers and teacher aides at Dev Academy interact with us. When needed we are given the time we need to solve a problem, rather then being given a possible solution to soon and we are also gently nudged in a certain direction when we might be going off on a tangent.

Our planning board started of with a user story and then we had a think about what we needed and then put the parts into the MVC design pattern.

planning board

We used a Kanban board when we got into the creating. I really liked the physical nature of using a whiteboard as I enjoyed being able to move the post it notes once tasks were complete.

kanban board

We unfortunately hadn’t gone over agile roles before we started. Even though as a group we worked really well, I feel that if our roles had been more defined rather then blended we may have been even more efficient. I guess a good learning opportunity!

So, what we made – Cocktail Suggester! Github link – https://github.com/libbyschuknight/cocktail_suggester and a demo.

I really enjoyed working on a group project, right from deciding on the idea to presenting our minimum viable product to everyone at EDA. There are couple of features we nearly got to – printing out the recipe of a cocktail, adding a cocktail to the list.

Cool things from this week:

  • learning about the ascii artii gem for the console art / fonts
  • on the macbook being able to swipe across when in full screen to go from presentation to code to terminal! (Got rather excited about this one – must be all the presentations I’ve done in the past where I couldn’t do that!)
  • oh and MVC has been good, it has tied in a lot of components that now make more sense!

Also this weekend, Rails Girls Wellington has been on at Enspiral Dev Academy and from all the tweets it sounds like it has been a great time. At the RailsGirlsWgtn weekend last year is where I was first introduced to Ruby and where I found out about EDA. A lot has happened since then and I never would have thought I would be actually a student at EDA. It has been one interesting year. I hope to in the future join the cool people that make RailsGirlsWgtn happen. For those that stepped into Ruby and Rails land this year, anything is possible!

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.  http://www.objectmentor.com/omSolutions/oops_what.html

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, http://en.wikipedia.org/wiki/Object-oriented_design

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.”  http://www.codeproject.com/Articles/567768/Object-Oriented-Design-Principles

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.

http://www.poodr.com/

download

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?