Using "class Object" for a project

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?

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, and in
fact you may need some of that functionality in your other classes.

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

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]

On Thu, May 19, 2011 at 8:50 PM, Robert D. [email protected]
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 G.

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

On Thu, May 19, 2011 at 7:21 PM, Markus H. [email protected] 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.