I'm designing a class capable of deserializing some file, and I'm wondering what would be the implications of this two options:
// option 1 - generic class
public class XmlConfigurationManager<T>
{
public T ReadConfigurationAndWriteDefault(string configurationPath, Func<T> defaultConfiguration)
{
...
}
public T Deserialize(string configurationPath)
{
...
}
}
// option 2 - generic methods in non generic class
public class XmlConfigurationManager
{
public T ReadConfigurationAndWriteDefault<T>(string configurationPath, Func<T> defaultConfiguration)
{
...
}
public T Deserialize<T>(string configurationPath)
{
...
}
}
I can't seem to find any hint on the differences between the two.
How do this two options compare? There would be any difference? Are there any notable points to keep in mind when evaluating the design?
I can think of one difference right away:
For example, if you want to simply deserialize the content of a file (json) to an object, a generic method would be enough as the needed type doesn't change anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With