On 3/14/07, Giles Bowkett <gilesb / gmail.com> wrote:
> I just solved a problem by adding an instance method to String.
>
> It makes for very elegant code elsewhere within the application.
>
> Yet I can't shake the feeling I've done something dirty.
>
> I think there needs to be a group like "Recovering Java Programmers
> Anonymous" or somehting.

I worked in Java for 5+ years, and am coming up on my one year
anniversary on working in Ruby professionally.  I *still* think adding
methods to core classes should be done very selectively, and only in
cases where that method is truly useful in a wide variety of contexts.
 So if adding "foo" to String just makes my code cleaner in one spot
where its called, but I know I probably won't use "foo" anywhere else,
then I'll go with the less elegant solution of a helper method instead
of extending a builtin.

Note that I"m speaking of a larger Rails project with multiple
distributed developers - if its just you and a small side project then
hack up the core classes all you want.  =)

- Rob