Quite often I find myself dealing with a pattern similar to this one
Two inheritance trees, where there is some kind of mirroring. Each of the subclasses in the left tree has a different subclass in the right tree as source
The MappingEnd class:
public class MappingEnd
{
public NamedElement source { get; set; }
}
The question is, how to deal with that in the subclasses. Do I hide the parent source property using the new keyword?
public class AssociationMappingEnd:MappingEnd
{
public new Association source { get; set; }
}
Or do I simply provide a second property casting the NamedElement to Association ?
public class AssociationMappingEnd:MappingEnd
{
public Association associationSource
{
get
{
return (Association)this.source;
}
set
{
this.source = value;
}
}
}
Why would I choose one over the other. Or is there a better way to implement this type of pattern?
