views:

88

answers:

5

I love those simple words such as "Object", "Property", "Value" and would like to use them as Class Names, but seems they are reserved. ( ? ) ROR failed on many things with a model named "Object"

Make a prefix doesn't look good, such as CCObject, CCProperty.

Is there a way to allow me to use those simple words directly?

What I want to do is a universe program, domain objects are generated at runtime, which means usually classes like Product, ProductType, Article, or Author are all datas in database, not an actually Ruby class.

A: 

You don't use them as Class names.. They are integral to ruby.

railsninja
+2  A: 

"Object" is already the name of a class in Ruby. It's the root class of everything in the language. That's why it appears to be "reserved" — because it's already taken.

Chuck
Is there any namespace thing we can do so I can use Object as a model name of ActionModel?
Cheng
+4  A: 

"Object" is a vey generic sort of word. Even if it WERE possible to create a class with that name, I'd be very suspicious of the need to do it.

Is there something that you could prefix it with that would let imply some context? For a dental office application, maybe "DentalOfficeObject". Is that what the "CC" prefix is for, or is it arbitrary to make the interpreter stop complaining?

FrustratedWithFormsDesigner
What I want to do is a universe program, domain objects are generated at runtime, which means usually classes like Product, ProductType, Article, or Author are all datas in database, not an actually Ruby class.
Cheng
How about naming the class "UniversalObject"?
FrustratedWithFormsDesigner
+8  A: 

How about not. Just don't do it. Even if it is possible, it's the easiest way to make your code completely unreadable and unmaintainable.

Deeksy
+1. Just don't.
Matt Darby
+1  A: 

My best bet would be Objekt, but still the name is adequate only if you're modelling an object model, which is silly.

Leonid Shevtsov