Hi everybody,

this is a bit of an annoying question once again. Some of you may know the is-keyword and the decorator pattern. (Short introduction below for those who don't, just to avoid strange replies to my question.)

For those who do not know the is-keyword:
I have been teached at school that it is rather bad practice to use the is-keyword, and can be avoided by using an interface IBlablabla which describes a "bool IsBlablabla()" function and implementing it all over the place. Personally I dislike this way of working, and I prefer the beauty of the is-keyword a lot.
A nice short description of what it does is available here: http://msdn2.microsoft.com/en-us/library/scekt9xw.aspx

For those who do not know the decorator pattern:
The decorator pattern can really save a lot of trouble in big complicated projects and is also sometimes used to avoid multiple inheritance problems. I will give you an example:

Let's say you want to make a car class:
public class Car{}

But you also want to add different kind of cars:
public class Truck : Car{}
public class Van : Car{}
public class Jeep : Car{}

Suddenly you notice you want to have Cars with radios:
public class CarWithRadio : Car {}

But what about a Trucks, Vans and Jeeps with a radios?:
public class TruckWithRadio : Truck {}
public class JeepWithRadio : Jeep {}
public class VanWithRadio : Van {}

Now you suddenly find out you want to have cars with headlights:
public class CarWithHeadLight : Car {}

Now what about cars with both headlights and a radio?:
public class CarWithHeadLightsAndARadio : CarWithRadio

The next thing you know also trucks and vans want to have headlights ...
in short ... to have cars, vans, jeeps and trucks with headlights, radio and a spoiler and all combinations of them you will need not just 7 classes but you will need (4.3.2+1).4 = 100 different classes . The decorator pattern is the answer here.

To implement it you just need to define a baseclass (Car) and a class per property which derives from that class: "van, truck, jeep, radio, headlights, ..." Next let every propertyclass keeps a reference to another instance. Next you can create instances like:

Van v = new Spoiler(new Headlights(new Radio(new Van(new Car()))));
makes a van with a headlight, radio and a spoiler.

For those who know both the is keyword and the decorator pattern
Maybe you can help me out. Because the Decorator pattern does not really make subclasses the is command will not detect all "property"-classes.

Or is there a trick that I am overlooking here, to make it work either way?

Thank you in advance