Factory class vs FromObject() method
In my application I have a class that is used to deserialize some response into objects. I have the Notification class and another class NotificationUnmarshaller. This has only one method:
 public IList<Noti开发者_JS百科fication> UnMarshal(PullResponse pullResponse)
I want to refactor this class into a public static method in Notification class. Something like:
public class Notification
{
    //members
    public static IList<Notification> FromResponse(PullResponse response}
    {
         //unmarshal
    }
}
In this a good design pattern? Is there any advantage of having a class with one single method to deserialize the response? Is the FromObject(...) method pattern a good one?
If all you are doing in this class is returning a deserialized object then I'd say no.
A generic template method works better for XML Serialization.
See: generic-xml-serializer-class
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论