November 02, 2007

Posted by John

Tagged class, presentation, rake, and rubyconf

Older: Marcel Molina: Beautiful Code

Newer: Nathaniel Talbott: Why Camping Matters

Jim Weirich: Advanced Ruby Class Design

“yes, these are your father’s parenthesis” – in regards to learning lisp

FORTH runs great in 2k of memory”

Box 1 Master of Disguise

Rake – FileList is like an array except initialized as GLOB, specialized to_s, extra methods (ext, pathmap, etc.), lazy evaluation (they don’t look at file system until they are iterated or whatever)

RESOLVING_METHODS.each do |method| 
	class_eval %{
		def #{method}(*args, &block)
			resolve unless @resolved
			# blah...
		end
	}
end

Box 2 (I didn’t see the name)

“Builder was a fun library to build. I wrote it just for the fun of it.”

Very cool stuff in builder. Install it if you haven’t and check out the BlankSlate class. It’s an object that doesn’t behave like and object.

Box 3 Parsing without Parsing

“how many people have written a ruby parser?” – everyone laughs because it’s probably just matz and his crew

Jim showed one way to begin converting ruby enumerable to sql generator. Created TableNode, MethodNode and a Node base. Node base implements methods such as == which converts stuff like users.age == 45 to users.age = 45 in sql. Problem ensues with literal strings (users.name == ‘jim’ converts to users.name = jim). He would add as_sql_node method to each object in ruby which means each object knows how it should be represented in sql.

Learn the corners of your laguage of choice to take full advantage.

Don’t be afraid to think outside the box of past experience…not all the time but occasionally ruby can provide very special solutions.

Conclusion

Jim’s talk was really interesting. More talks should be like this. He gave practical examples of how to solve interesting problems which really opens up your mind.

0 Comments

Sorry, comments are closed for this article to ease the burden of pruning spam.

About

Authored by John Nunemaker (Noo-neh-maker), a programmer who has fallen deeply in love with Ruby. Learn More.

Projects

Flipper
Release your software more often with fewer problems.
Flip your features.