Main Content

Object Orientation in Ruby - intermediate examples

Archive - Originally posted on "The Horse's Mouth" - 2009-07-16 15:52:22 - Graham Ellis

It's when you teach object orientation - the fully Monty, including inheritance, static and dynamic methods and variables, and so on - to a complete novice to programming and that person finds it's one of the easiest parts of the course that you realise:

a) Just how many bad ole habits us ancient structure programmers have gotten ourselves into and ...

b) What an excellent and natural Object system languages like Ruby have. T hat's as compared to C++ with a bevy of files, Java with so much security it obscures the simplicity, or Perl with so many options and so much ability to sidestep objects. (Python has a similar, and great, philosophy too)

Here are the 'second level' examples from today - not the basic object stuff, which you'll find if you look back a couple of days.

[link] Single class example for extension by inheritance

[link] Object and Class variables (dynamic and static)

[link] Static Method in Ruby

[link] Inheritance in Ruby