This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit e4618c2401d9197ac102e2e75217df30ba3a1016
tree 0816200ccfff1172f109e4b10e1ecd113200d4ab
parent f83937670289e08a49faef074d909e33dd99c909
tree 0816200ccfff1172f109e4b10e1ecd113200d4ab
parent f83937670289e08a49faef074d909e33dd99c909
| name | age | message | |
|---|---|---|---|
| |
README.textile | Sun Sep 27 08:16:21 -0700 2009 | |
| |
examples/ | Sun Sep 27 06:59:54 -0700 2009 | |
| |
slides/ | Sun Sep 27 08:24:07 -0700 2009 |
README.textile
What the heck is that?
These examples are from Ruby BarCamp ’09 in Kiev, Ukraine. I did not really prepare much, and
I had no slides at all, hence all the comments in this repository.
Points of the talk
- Ruby object model is beautiful and rich. Learn it as good as you can.
- Using rich object model and all the features built into it is way better
compared to inventing your own OOP (e.g. alias_method_chain) or just
not following three main ideas of OOP (incapsulation, inheritance, polymorphism)
- Modules are the cornerstone of Ruby’s object model
- Module inclusion results in an anonymous class being created in hosting class’ inheritance chain
- Because of previous point, yon can call super from Module methods.
- alias_method_chain was invented simply because some people did not know about this
powerful feature of Ruby’s object model back in 2005
- super works for methods of class objects (like Person.find or Person.all), too
- Module + super does not solve all the library incompatibilities issues, but it helps
a lot compared to alias_method_chain and other “screw incapsulation, I can do whatever I want”
kind of inventions
- class_eval replaces method implementation forcefully, and breaks superclass method calls
- Safe way to do class_eval is to use Module.new, then class_eval on the module, and include it
- And beware of local var vs. accessor with self issue when writing modules (and not just modules)
- Rails 3 codebase is almost alias_method_chain free now. You bet, this means something.
Useful links
I personally learned a lot more about Ruby object model from Smalltalk books and articles than
from Ruby books and blog posts. A lot of Smalltalk books are in public domain or available for free.
Here is a few:
- Collection by Stéphane Ducasse
- Metaclasses in Smalltalk
clearly explains what metaclasses are why metaclasses came to be in the first place.
- Ruby Hacking Guide translated from Japanese is invaluable, especially if you are fine with C







