I'm having a great time lately learning more about Ruby's subtle features, like metaprogramming. I find that the more declarative I can be in my class definitions, the less chance there is for runtime errors based on faulty instance initialization. By the way, a tip of the hat as usual to why. He infuses great technical content with bizarre humour.
This doesn't really look like standard Ruby, but I enjoy the readability...
class MonitorListener < Listener port 2700 mountpoint :mon prefix :mon addr "127.0.0.1" impl :MonitorListenerImpl end
I know a priori that "Monitor" implies those other values, so why not encode them in a type that knows what it's doing, rather than the more usual
mon_obj = Listener.new("127.0.0.1", 2700, "mon"...)
What I really wanted to say is... I'm sitting here editing code on one monitor and watching "Wrath of Khan" on the other :)
I refuse to apologize.
Posted by cbrown at January 7, 2006 5:37 PM