This is funny because another StackOverflow user shows such an example a couple of hours ago in his question .
Consider this class:
[Serializable] class MyClass {
This class (MyClass) has several separate roles:
In many cases, this is not a good idea, because we cannot easily reuse this serializable object when we want to change our persistent storage from a simple binary file to an Xml file or to remote storage (for example, through WCF).
You can create subclasses, such as MyClassWCFSaver, but even then it is much easier to use the serializable class MyClass and the independent hierarchy MyClassSavers (with several different subclasses for xml, binary, or WCF repositories)
By the way, this is why in many ORMs we often distinguish entities from the repository (see the repository template ).
source share