[Nitro] Interesting web framework article

Lars Olsson lasso at lassoweb.se
Wed Feb 21 11:35:28 EST 2007


Hi!

The dynamic nature of ruby makes it extremely easy (perhaps too easy) to
extend the core of the language. Both rails and nitro extends things like
String, Array and even Object. That makes it quite difficult to get some
libs to get along.

I sometimes wonder why inheritance/namespaces isn't used in ruby more
often to avoid these kinds of clashes. Even though the syntax gets a
little ugly, you don't 'taint' the core classes with you super extra cool
functionality.

Silly example:
module Foo
    class Bar < String
        def revup
	    self.reverse.upcase
        end
    end
end
include Foo
baz = Bar.new("one two three")
p baz.revup

which gets us: "EERHT OWT ENO"

The syntax is a litte ugly, but our Strings are safe. Compare this to:

class String
    def revup
        self.reverse.upcase
    end
end
baz = "one two three"
p baz.revup

which is only good if we want *all* strings to have this method. But how
often is that kind of method *really* what we need?


Sincerely

/lasso



> Interesting.
>
>
> The problem I've run into with mixing up assorted framework parts is the
> conflict of libraries.  For example, one *should* be able to use Rails view
> and controller parts with Og, but I've never gotten it to work.  I think
> facets or glue get into arguments with ActiveSupport of actionpack or
> something.
>
> It would be nice if the Web end of stuff was abstracted from the app end
> of stuff, but then the app stuff needs be cleanly decomposable as well and
> each supporting library cleanly name-spaced, .
>
>
> --
> James Britt
>
>
> "Design depends largely on constraints."
> - Charles Eames
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>
>




More information about the Nitro-general mailing list