Day 9 – Program organization, Part 1 of 3.
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.