This week was focusing on Object Oriented Design. We had 5 challenges to do:
- Drawer Debugger
- Pez Dispenser
- Bingo Board Part Two
- Refactoring for Code Readability – on previous weeks challenge Validate a Credit Card Number
- 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.
Another book with an interesting title:
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.
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:
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?