This may be a little subjective, but I would like to receive your contribution to my current situation. I have a class that will be used to serialize / deserialize an object.
public class MyClass
{
public static string ToXmlString( MyClass c ) { }
public static MyClass FromXmlString( string xml ) { }
}
I only like this approach because it supports two functions at the same level. However, my goal is to avoid using static methods (whenever possible). It also looks like I can be vilolating SRP, but the main purpose of this object is that it can be serialized / deserialized from an xml string.
Any thoughts on using static methods in this situation? Should I just do ToXmlStringnon-static, but leave the statics FromXmlString? Should I create a new class that will only handle MyClass serialization?
EDIT:
The class that I am discussing here is a simple transfer object. It is used to save / restore values from the thrid party tool.
Thank!
source
share