使用选项 1 和 2,如果您决定更改 XML 模式(或者如果您认为 XML 太冗长,或者您想要包含加密等),那么您现在可能必须更改数据对象实现 - 与选项3不好。
您是否绝对确定当前的 XML 消息集将是数据发生更改的唯一原因?我的意思是真的绝对100% 确定没有人不想使用XML?如果没有,则选择 4。将实现(数据对象)与接口(XML 消息)解耦是确保代码可维护的最佳方法。
I'd suggest option 4, mostly because you probably don't want your data objects to be so closely tied to the message transport mechanism.
With options 1 and 2 if you decide to change your XML schema (or if you decide that XML is too verbose, or if you want to include encryption etc etc) then you probably now have to change your data object implementation - the same reason that option 3 is bad.
Are you absolutely certain that your current set of XML messages will be the only reason that data will change, ever? I mean really absolutely 100% certain that no-one will ever not want to use XML? If not, then go with 4. Decoupling implementation (data object) from interface (XML messages) is the best way to ensure your code is maintainable.
发布评论
评论(1)
我建议使用选项 4,主要是因为您可能不希望数据对象与消息传输机制如此紧密地联系在一起。
使用选项 1 和 2,如果您决定更改 XML 模式(或者如果您认为 XML 太冗长,或者您想要包含加密等),那么您现在可能必须更改数据对象实现 - 与选项3不好。
您是否绝对确定当前的 XML 消息集将是数据发生更改的唯一原因?我的意思是真的绝对100% 确定没有人不想使用XML?如果没有,则选择 4。将实现(数据对象)与接口(XML 消息)解耦是确保代码可维护的最佳方法。
I'd suggest option 4, mostly because you probably don't want your data objects to be so closely tied to the message transport mechanism.
With options 1 and 2 if you decide to change your XML schema (or if you decide that XML is too verbose, or if you want to include encryption etc etc) then you probably now have to change your data object implementation - the same reason that option 3 is bad.
Are you absolutely certain that your current set of XML messages will be the only reason that data will change, ever? I mean really absolutely 100% certain that no-one will ever not want to use XML? If not, then go with 4. Decoupling implementation (data object) from interface (XML messages) is the best way to ensure your code is maintainable.