views:

323

answers:

7

So I've become a reasonably proficient Rails developer, and I'm finding that my bottleneck is now my lack of understanding of more complex Ruby constructs. I'm trying to build some plugins, and looking at some complex ones out there, their OOP wizardry is Greek to me. (I never had much formal OOP training so that's part of the problem.)

I want to better understand:

  • Sending methods from one place to another (include, extend, etc...)
  • Metaprogramming & overriding methods (super)
  • Class inheritance, modules, etc

Serious Ruby tomes seem like too much. Is there a pragmatic way to learn this stuff that will extend my powers without overwhelming me in the inner workings of the language?

+3  A: 

The best way is to use it and learn by looking at code from others.

I don't think that there's a better place to start than the official documentation page.

Sorry if I've disappointed you, but there's no easy way to learn all those constructs.

Georg
+4  A: 

You can also take a loot at some books, for example, the Pickaxe: http://whytheluckystiff.net/ruby/pickaxe/

Take a special look at the OOP and metaprogramming sections.

fsanches
+2  A: 

I've found the ruby quiz to be a terrific resource to sharpen your knowledge of ruby. You can buy the book version or just use the entries at the site. Different problems will lend themselves to using different parts of the language.

Denis Hennessy
A: 

You can also try and learn the basics of another langauge (Java or C# for instance).

I think learning a new language can be a very efficient and fun way to familiarize yourself with different approaches to solving problem (in your case object-oriented programming concepts).

Once you know how to code, learning the basics of a new language is both relatively easy and extremely entertaining, so you tend to make progress extremely fast at the beginning

And when you're trying to grasp concepts that are new to you, it might be easier to understand them in a framework that's also new. That way you can focus on the concepts you're trying to learn, and not on the way you could solve this problem differently in your language, etc...

Axelle Ziegler
+1  A: 

the best way to start is understanding how class hirarchies really work internally so you know what gets call when. in otherwords you need to understand metaclasses.

here are the two resources that helped me the most to understand the concept: why´s explenation and another one

you could also try these ruby plus screencasts. there are alot about other topics you seem to be intrested in

LDomagala
+2  A: 

I found these screencasts by Dave Thomas to be great for that, besides, it has pragmatic in the title so you can't miss :D

krusty.ar
Yes! I stumbled on these yesterday and it seemed like the closest I've gotten. Will definitely be going through them.Do they cover stuff like sending methods to other classes / controllers? Not sure what's included in 'metaprogramming'.
I don't undestand what you mean by "sending methods to other classes/controllers", but if you mean how to use extend and include, then the answer is yes.
krusty.ar
+1  A: 

This Peepcode plugin patterns pdf actually answered all my questions; what I was trying to do was write a plug-in so it was exactly the information I needed.