For my new Pet-Project I have a question for design, that is decided already, but I want some other opinions on that too.
I have two classes (simplified):
class MyObject
{
string name {get;set;}
enum relation {get;set;}
int value {get;set;}
}
class MyObjectGroup
{
string name {get;set;}
enum relation {get;set;}
int value {get;set;}
List<MyObject> myobjects {get;set;}
}
Later in the Project MyObjectGroup
and MyObject
should be used equally. For this I could go two ways:
- Create an interface:
IObject
- Create an abstract class:
ObjectBase
I decided to go the way of the interface, that I later in code must not write ObjectBase
every time but IObject
just for ease - but what are other positives for this way?
And second, what about adding IXmlSerializable
to the whole story?
Let the interface inherit from IXmlSerializable
or does it have more positives to implement IXmlSerializable
in abstract base class?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…