The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
RubyConf 2007 Friday Morning - Jim Weirich

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Rick DeNatale

Posts: 269
Nickname: rdenatale
Registered: Sep, 2007

Rick DeNatale is a consultant with over three decades of experience in OO technology.
RubyConf 2007 Friday Morning - Jim Weirich Posted: Nov 2, 2007 11:02 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Rick DeNatale.
Original Post: RubyConf 2007 Friday Morning - Jim Weirich
Feed Title: Talk Like A Duck
Feed URL: http://talklikeaduck.denhaven2.com/articles.atom
Feed Description: Musings on Ruby, Rails, and other topics by an experienced object technologist.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Rick DeNatale
Latest Posts From Talk Like A Duck

Advertisement

Jim's talk was entitled "Advanced Ruby Class Design"

He started out talking about his own background with various programming languages and how influences from experience with other languages can both help and hamper learning Ruby. He said that while some things from Java/C++ like modularity carry over usefully to Ruby, but, that some very useful Ruby techniques are inconceivable to Java/C++ programmers.

Unlike Wallace Shawn's Vizzini, I'm pretty sure that Jim really does know what that word means.

He gave some examples of this from his "Classics", unfortunately, my note-taking skills are such that I can't capture enough to go into them in detail.

  1. From Rake, an example of why the FileList class, which acts like an Array broke because it was initially implemented as a subclass of Array. The fix was to NOT make it a subclass of Array, something which can blow the mind of someone coming from a statically typed OO language.
  2. From Builder, which uses "method_missing" to turn Ruby method calls into XML, a problem caused by interference between domain names, like 'class', and core Ruby object methods. The solution was to create a BlankSlate class which undefines most of it's inherited methods (it spares methods like __id__, and __send__). Then he found that he also needed to deal with methods added to Kernel and Object after BlankSlate was loaded. To do this he used method_added_hooks in Kernel and Object so that BlankSlate could remove newly added methods as they were defined. This later changed to use the append_features hook instead to catch methods added to Object or Kernel by module inclusion. Again, this is something which really requires coming from a less dynamic language to "Think outside the box."

He made another foray into "Parsing without Parsing" a Ruby technique for tracking the execution of a Ruby block with method_missing and proxy objects to "parse" the "source" of the block and capture an object graph representation. His motivating example was doing something like Err the Blog's Ambition which generates SQL queries from Ruby blocks. He gave lots of useful Ruby metaprogramming tips, up to and including where Ruby limitations led him to abandon this approach for SQL generation. Because of things like the inability to handle "syntactic sugar" operators like && and || since they aren't implemented as methods, he felt that these restrictions on contents of the block left him short of his goal to express the query in "natural" Ruby.

But the technique itself is quite useful, and finds use in tools like FlexMock and RSpec.

All in all a very thought provoking presentation from Jim. I hope he makes the slides available soon.

Read: RubyConf 2007 Friday Morning - Jim Weirich

Topic: My Ingres Ruby and Rails Driver is Available Previous Topic   Next Topic Topic: Rails: Array#to_sentence

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use