Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #4771 > unrolled thread

Using "class Object" for a project

Started by"Markus H." <shevegen@gmail.com>
First post2011-05-19 12:21 -0500
Last post2011-05-19 15:05 -0500
Articles 5 — 5 participants

Back to article view | Back to comp.lang.ruby


Contents

  Using "class Object" for a project "Markus H." <shevegen@gmail.com> - 2011-05-19 12:21 -0500
    Re: Using "class Object" for a project Joel VanderWerf <joelvanderwerf@gmail.com> - 2011-05-19 12:58 -0500
    Re: Using "class Object" for a project 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-19 12:37 -0500
    Re: Using "class Object" for a project Robert Dober <robert.dober@gmail.com> - 2011-05-19 13:50 -0500
      Re: Using "class Object" for a project Phillip Gawlowski <cmdjackryan@googlemail.com> - 2011-05-19 15:05 -0500

#4771 — Using "class Object" for a project

From"Markus H." <shevegen@gmail.com>
Date2011-05-19 12:21 -0500
SubjectUsing "class Object" for a project
Message-ID<a758af90f801ff5df85c80e0f184f560@ruby-forum.com>
Hello.

I am currently contemplating writing a MUD in Ruby. (I don't mind how
"slow" ruby would be.)

Now there is a lot of unfinished code so far, but I was wondering about
one thing actually:

I am thinking of a base class for all the objects in this MUD. Naturally
the first thought I had would be:

class Object

But of course this won't work because ruby itself uses this class name.

Now, what I will be doing is to use another name other than "Object" for
all the base class for all Objects in the MUD.

But I was thinking:

- Is there any way to use a class name like "Object" on a per-project
base?

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [next] | [standalone]


#4772

FromJoel VanderWerf <joelvanderwerf@gmail.com>
Date2011-05-19 12:58 -0500
Message-ID<4DD55A31.4070205@gmail.com>
In reply to#4771
On 05/19/2011 10:21 AM, Markus H. wrote:
> - Is there any way to use a class name like "Object" on a per-project
> base?

Put it in a module?

module MyMUD
   class Object
   end

   p Object
   p ::Object

   class Foo < Object; end
   p Foo.ancestors
end

__END__

Output:

MyMUD::Object
Object
[MyMUD::Foo, MyMUD::Object, Object, Kernel]

[toc] | [prev] | [next] | [standalone]


#4774

From7stud -- <bbxx789_05ss@yahoo.com>
Date2011-05-19 12:37 -0500
Message-ID<717fee52af6aefd4dc83b6d8d78b6347@ruby-forum.com>
In reply to#4771
Are you really that attached to the beauty of the word "Object"?

If you must use the name Object, you can always delete all the methods 
in Object(note that in ruby 1.9.2 the top class is BasicObject).  But 
'monkey patching' like that can affect the clients of your code--they 
may expect to have ruby's normal functionality available to them.

The easiest thing to do is just misspell Object, e.g. Obgect, Objekt, 
MyObject.

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#4778

FromRobert Dober <robert.dober@gmail.com>
Date2011-05-19 13:50 -0500
Message-ID<BANLkTingUJrG38EmNBu-EB5M0-CzBVbS2A@mail.gmail.com>
In reply to#4771
On Thu, May 19, 2011 at 7:21 PM, Markus H. <shevegen@gmail.com> wrote:

> Now, what I will be doing is to use another name other than "Object" for
> all the base class for all Objects in the MUD.
I am most curious why you want to have a base class for all classes in your app?
Can you think of something which they all are? If not you are probably
not making the best design choice here.
Cheers
R.
-- 
You’ll never be up to date, but you can be ahead
-- Kent Beck

[toc] | [prev] | [next] | [standalone]


#4782

FromPhillip Gawlowski <cmdjackryan@googlemail.com>
Date2011-05-19 15:05 -0500
Message-ID<BANLkTin59eNeiMua2ASZE3f1eB0UdDZNmQ@mail.gmail.com>
In reply to#4778
On Thu, May 19, 2011 at 8:50 PM, Robert Dober <robert.dober@gmail.com> wrote:
>
> I am most curious why you want to have a base class for all classes in your app?
> Can you think of something which they all are? If not you are probably
> not making the best design choice here.

Every thing in a MUD/IF has a location, description, material
(possibly), bulk, visibility, smell, and a name, and methods
interacting with these properties.

-- 
Phillip Gawlowski

A method of solution is perfect if we can forsee from the start,
and even prove, that following that method we shall attain our aim.
               -- Leibnitz

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web