In this case, you could avoid the conditional logic by overloading the invoicemethod for different types.
在本例中,通过为不同类型重载invoice方法,您可以避免条件逻辑。
2
If you define an invoicemethod on a class, you have no way of knowing that some other user of that class won't define a different, incompatible method also named invoice.
And this implementation is closed: After you compile the FulfillmentGenerator class, you can't extend the invoicemethod to new types without editing the source code and recompiling.