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


    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") {


    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

    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


    "There is always more to say"
    rolo, Apr 6, 2004
    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
    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"

    def bar
    puts "world"

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

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

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

    Robert Klemme, Apr 9, 2004
    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.