开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜