Object oriented does not mean class oriented

Discussion in 'Ruby' started by rolo, Apr 6, 2004.

  1. rolo

    rolo Guest

    Hi all,

    I see for every class i declare, it is basically a new object extending the class object.

    class MyClass < BaseClass

    end

    I think apart from class, I should be able to declare many other constructs like Bean etc.

    so class declearations are something like this

    Class.new("MyClass","BaseClass") {
    method.new("MyMethod"){

    }
    }

    But for ease of reading and declearations we use the present ruby form.

    How wonderfull it would be if we can define Bean like that:

    Bean MyBean < BaseBean
    attributes :name
    end

    I know we can do this in the current ruby. But it would be better if we switch to something like this.

    Class MyClass < BaseClass
    end


    regards,
    rolo

    "There is always more to say"
    http://www.c2.com/cgi/wiki?EasternPhilosophyInSoftwareDesign
     
    rolo, Apr 6, 2004
    #1
    1. Advertisements

  2. rolo

    Dan Doel Guest

    I'm not sure I understand your proposal.

    How is Bean different than a class? What makes

    Bean MyBean < BaseBean

    different from

    class MyBean < BaseBean

    ? Or is it a matter of being more specific in the naming (e.g. you know
    whether you're defining a regular Class or a Bean class)?

    Could you explain a bit more?

    - Dan
     
    Dan Doel, Apr 6, 2004
    #2
    1. Advertisements

  3. I'm not sure if I understand you correctly, but these two things are
    very possible already in the current Ruby:

    1) MyClass = Class.new(BaseClass) do
    define_method:)foo) do
    puts "hello"
    end

    def bar
    puts "world"
    end
    end

    2) def Bean.new_class(&block)
    Class.new(Bean, &block)
    end

    MyClass = Bean.new_class do
    def a; end
    define_method:)b) do; end
    end
    More regards,
    Florian Gross
     
    Florian Gross, Apr 6, 2004
    #3
  4. switch to something like this.

    What do we gain by this? What is it that you want to achieve?

    robert
     
    Robert Klemme, Apr 9, 2004
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.