开发者

What is the best way to restrict strings in an Object Oriented model?

开发者 https://www.devze.com 2023-02-16 05:23 出处:网络
I need to select a modeling method for documenting extensions to an existing collection of web services.The method/tool needs to be used by tech business analysts. The existing API is defined in XML S

I need to select a modeling method for documenting extensions to an existing collection of web services. The method/tool needs to be used by tech business analysts. The existing API is defined in XML Schema. XML Schema work well with the one exception. Take a PaymentInformation class as an example. One partner might accept Visa and Mastercard as an example. Another also excepts Amex. We want to be able to extend PaymentInformation for PartnerA and PartnerB.

class PaymentInformation
   method // CASH,CC
   ccNumber
   ccType  // MC,V,AMEX

class PaymentInformationPartnerA
   method // CASH,CC,PAYPAL
   ccNumber
   ccType // MC, V

The proble开发者_StackOverflow中文版m with XML Schema is that to apply a restriction to a class requires redefining the whole type. This seems like a maintenance nightmare. UML doesn't seem to support restricted strings (patterns, length, etc). What tool/method do you recommend for this? We have a preference, but not a requirement for Eclipse IDE.


You can add an UML constraint or a condition on your class. This is either a graphical note or directly an information hand coded on the UML metamodel. The UML model is already an XMI 2.1 therefore like a XML but using specific rules.


Don't do that. If PaymentInformationPartnerA extends PaymentInformation then for all uses of PaymentInformation you can use PaymentInformationPartnerA, whereas you are saying that for some uses ( assigning a value to ccType of "AMEX" ) it is not covariant.

You're probably better off putting the constraint as a pre-condition of the endpoint receiving the message rather than as a constraint on the message type itself.

0

精彩评论

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