This project is read-only.

Checking for dummy

Topics: Metadata Model
Jan 4, 2011 at 2:36 AM


Often I need to check if an item is dummy, most frequently a type definition of some kind or a method definition or a reference.

The problem is that you have to check against a number of instances. For example a ITypeReference can be Dummy.TypeReference but also Dummy.Type or any other kind dummy of ITypeDefinition (there are several of them). And what if next month you add a derived interface with its official dummy instance: the check is now broken!

Could you add an IsDummy property at the very base interface types of your model?

I don't think it would need to be implemented but in few places.


Jan 4, 2011 at 5:51 AM

This seems like a good idea, but I don't really like "IsDummy" as a name.

I should perhaps also mention that the intention of the object model is that you only ever need to check for one kind of Dummy. If the property you want to check is of type ITypeReference, then the value returned must be exactly Dummy.TypeReference and not any other object that might also happen to implement ITypeReference (for example, Dummy.Type).

I've had a quick look at at all of the references to Dummy.Type and there are a few cases where this intention has not been honored. I'll try to get those fixed soon.

Jan 4, 2011 at 7:02 AM
Edited Jan 4, 2011 at 7:09 AM

Honoring that is easy for the return value of a method.

In general, it's very common for me to, say, store a generic type instance into a ITypeDefinition property of an object and later pass it as a ITypeReference to a method that will use it for something else.

The name is not a problem for me. What about "IsValid" or "IsNotValid"? I like "IsDummy" more tho.. or "IsDummyInstance"? 

I don't like "IsValid"/"IsNotValid" because there are cases where a dummy instance is enough meaningful and valid.

Jan 7, 2011 at 8:58 PM

I have now made class Dummy into an abstract base class and changed all of the dummy classes to extend it. You can now ask "x is Dummy" for any dummy value x and expect the expression to be true.

Jan 8, 2011 at 5:38 AM

Since I guess there should be no need for multiple "dummy" implementations this option  is as good as the "IsDummy" property but is much more "elegant".

I'll update my copy and my checks in few minutes. :-)



Jan 8, 2011 at 10:51 AM

Probably there is a delay because I still don't see the changes. I'll check it again later.