Day 9 – Program organization, Part 1 of 3.
Back in my review of The Object-Oriented Thought Process, I talked about the difference between
is a and
has a in programming world. Dave was then kind enough to clarify.
Today’s chapter was that. In practical, We’re-Writing-Code terms, rather than the abstract, This-is-How-To-Think-About-It way of the previous book.
Here’s a quick background in Object-Oriented Design for the non-programmer:
- Methods are chunks of code that do Useful Things.
- Classes are collections of, among other things, Methods.
- Rather than rewriting a Method to reuse it in another class, it can be imported into both Classes – as a Module.
- Multiple Modules can be imported into a single Class
- If 2 Modules imported into the same Class contain 2 different Methods with the same name, Ruby says the last one imported is the default.
Sometimes, the only way to stay responsive and relevant is to process things on a ‘last in, first out’ manner. I’m glad Ruby feels the same way.
This post documents my journey through Sam’s Teach Yourself Ruby in 21 days. I’ll be joining Al Abut in his effort to learn Ruby and blog along the way.