Using "class Object" for a project

M

Markus H.

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?
 
7

7stud --

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.
 
J

Joel VanderWerf

- 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]
 
R

Robert Dober

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.
--=20
You=92ll never be up to date, but you can be ahead
-- Kent Beck
 
P

Phillip Gawlowski

I am most curious why you want to have a base class for all classes in yo= ur 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.

--=20
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.
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Leibnitz
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top