C# new class with only single property : derive from base or encapsulate into new ?
Posted
by Gobol
on Stack Overflow
See other posts from Stack Overflow
or by Gobol
Published on 2010-03-19T18:27:16Z
Indexed on
2010/03/19
18:31 UTC
Read the original article
Hit count: 156
I've tried to be descriptive :) It's rather programming-style problem than coding problem in itself.
Let's suppose we have :
A:
public class MyDict {
public Dictionary<int,string> dict;
// do custom-serialization of "dict"
public void SaveToFile(...);
// customized deserialization of "dict"
public void LoadFromFile(...);
}
B:
public class MyDict : Dictionary<int,string>
{
}
Which option would be better in the matter of programming style ? class B: is to be de/serialized externally.
Main problem is : is it better to create new class (which would have only one property - like opt A:) or to create a new class derived - like opt B: ? I don't want any other data processing than adding/removing and de/serializing to stream.
Thanks in advance!
© Stack Overflow or respective owner