Friday, January 12, 2007

Overloading a method within a class.

I came to an interesting realization today what I came home from work and started to look through what had been posted to comp.lang.ruby. The language I program in has drastic effects on my design. Actually, I guess I've always thought to that be true. That's probably why I prefer to do certain things in one language over another. Anyway, enough of my being theoretical. Read this.

What I find fascinating is that in over two years of hacking ruby it has never even once occurred to me that I couldn't overload a method within a class. Why? Because Matz and the other Ruby commiters have found it to be a Bad Thing(TM) and Ruby encourages you to do good things. Yeah, yeah, if you read the whole thread another reason for not implementing it is because it would be hard to do. With that aside I've already started to loathe seeing multiple constructor signatures in a class and that's pretty much the same thing. Just make a static constructor and give it a name that actually means something. None of this 'new Foo(x); new Foo(x,y); new Foo(x,y,z)' trash.

No comments:


my google reader feed