且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

代表这种图的常见方法是什么?

更新时间:2023-11-20 19:44:58

您应该从问题域的模型开始。我会期望像下面这样:





此图说明:




  • A 客户 更多付款支付给付款服务

  • A 付款服务 接受一个或多个付款$ c> >客户

  • 每个付款都有金额

  • A 付款必须是里程付款现金付款信用卡付款

  • 付款 s



为了解答您的问题,让您的 pay()方法接受一组付款。对于每种 Payment ,不需要下级接口,只需要各种类实现。我会使用多态操作来借记(如果这是正确的单词),如果有任何失败,回滚,并在所有的借记成功时提交。


I need to represent the payment of a customer to buy a flight ticket in an airport. The system of airport has a bonus system.

So customer can make payment for ticket by a bonus or by another payment system or together. But I don't know how to represent it all together.

I wanna make the interface that called PaymentMethod and make this hierarchy : ByPaymentSystem(Interface), ByBonuse(Class), ByMix(Class that dependet from ByPaymentSystem)

Payment system will also have many realizations f.e. : webmoney, mastercard and so on.

And also I wanna make a PaymentService class that will have method pay that will take a parameter method:PaymentMethod and also take an specific information about the kind of payment.

I am not sure about ByMix class, and my spirit wanna avoid this class.

What do u think about it ?

Please don't break down my reputation but just comment your opinion. I will review them and than make decision about destiny of this topic. Also I prepeare imagine all my thoughts about subj in UML class diagram if that will be necessary.

This is the my draft of a part of my diagram

I wanna make something like that but i don't know how to deal further. How to represent payment by mixed case: by bonuses and by credit cash.

UPD: This project is the site of an avia-company. The company have bonuse miles system. That means the frequently flying customers can receive some free kilometeres bonuses by that they can pay some part of a flight. Of course they can make payment by credit card or even combine that methods. - there I have stock. How to represent that combination ?

I need to represent the class diagram that will satisfy the desires above.

UPD:

You should start with a model of the problem domain. I would expect something like the following:

This diagram states that:

  • A Customer offers one or more Payments to a Payment Service
  • A Payment Service accepts one or more Payments offered by a Customer
  • Each Payment has an amount
  • A Payment must be a Mileage Payment, Cash Payment, or Credit Card Payment
  • There is no overlap among the types of Payments

To then answer your question in terms of the solution domain, I would have your pay() method accept a collection of payments. You don't need subordinate interfaces for each kind of Payment, only various class implementations. I would use polymorphic operations to debit (if that's the right word), roll back if anything fails, and commit when all the debits succeed.