views:

67

answers:

1

Hi,

We have services which are either Educational Cess only, Taxable, Non-taxable. Taxes can further be of the following types: Fringe, Sales, Excise, Octroi, Educational Cess, Subsidy, Other Local taxes.
We are planning to implement the calculation of taxes using a visitor. What would be the best choice for the Visitable class/interface, Service or TaxCategory.

The number of categories will be limited to a combination of the types of taxes. Services are like customizable products and can be expected to be about 3000+. Each service will have a TaxCategory member.

There may be certain services which may fall under a given tax category, but still have additional taxes/subsidies.

Kind regards,

+1  A: 

Since we're talking about the Visitor/Visitable design pattern here, I would say the Visitable/accept interface really should be on the TaxCategory. The idea of the visitor pattern is to have the visitor go into the visitable, perform some operations, and fetch back some result.

That sounds like a perfect description of what you need to do with each TaxCategory. Go in, perform the requisite calculations in the context of that tax, and get back the value you need.

Hope that makes sense.

Gabriel Hurley