I'm trying to serialize, and I am facing a problem with an abstact class.
I googled for an answer, and I found this blogitem. I tried that and that work.
Ok, very nice. But check out the comment on the item:
This methodology seems to be hiding the true problem and that is an inaccurate implementation of OO design patterns, namely the factory pattern.
Having to change the base class to reference any new factory class is self-defeating.
With a little after-thought, the code can be changed to where any derived type can be associated with the abstract class (through the miracle of interfaces) and no XmlInclude would be required.
I suggest further research into factory patterns which seems to be what you are trying to implement here.
What is commenter talking about? He is kinda vague. Can someone explain it more in detail (with an example)? Or is he just talking nonsense?
Update (after reading the first answer)
Why does the commentor talk about
factory pattern
and
the code can be changed to where any derived type can be associated with the abstract class (through the miracle of interfaces)
?
Does he want to make an interface, like this?
public interface IWorkaround
{
void Method();
}
public class SomeBase : IWorkaround
{
public void Method()
{
// some logic here
}
}
public class SomeConcrete : SomeBase, IWorkaround
{
public new void Method()
{
base.Method();
}
}