Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Taxation class design - interface / inheritance / none 1

Status
Not open for further replies.

craigmcguff

Programmer
Mar 4, 2005
2
NZ
I have a set of procedural code for tax calculations for Australia and New Zealand that I want to implement in a more logical class design (C#).

On the face of it they seem simlar, both ultimately calculate an amount of tax, based on a given tax code, date, gross pay etc.

Where they diverge is in the number and type of both input and output parameters. Umm let's see if I can clarify that...

NZ requires 3-4 parameters to calculate the amount, the return amount is actually 3 separate figures added together of which we may need the individual components.

Australia is the same but there is a larger number of input parameters, and the return amount may have up to 4-5 components.

I am struggling to come up with a consistent interface for this and I am looking for some fresh input.

Should I use an interface or build a class hierarchy, or is there no real relationship?

I suspect I need to build an input object and an output object that can be specialised by country.

Thoughts?
 
On the face of it, they may seem similar. But the number of input parameters, number of output parameters, and the actual calculations are all different. In fact, there is almost nothing the same about them.

Assume for a moment that the 'larger number of parameters' for AUS is a superset of the 3-4 needed for NZ, then you could always ask for the same number of parameters regardless, and then submit it to the appropriate object for processing. But unless you use a factory, the client will always need to know what kind of TaxCalculator object it needs. If you need to be able to collect the data, perform both calculations, and then compare the results to determine if you'd be better off if you lived somewhere else, then there might be some benefit. But if not, then I don't really see what advantage there is in trying to merge the two.
 
Thanks for the reply. This has been bugging me for a while, on the face of it, it seems as though you could create an extensible set of classes that could manage many countries taxation, but it's just so much more effort than keeping them separate. As you say the only real thing is common is that they deal with tax :)

I just though of an analogy - MS Word and Excel are both documents... <s>

Thanks again, I just needed a fresh set of eyes to crystallise what I was thinking.

 
Hey,
how many countries are u dealing with and how different are the algorithms for calculation?

Can any 2 countries share the same algorithm? if so, encapsulate each algorithm into its own class. Use a generic TaxCalculator that makes use of a different strategy for calculating.


Example:
TaxCalculator.Calculate(new ZealandStrategy(requestObject));


The client is normalized against change. It only hands over the entire request object with the values take from the form/gui. The strategy picks out what it needs and calculates tax based on those params effectively handing back a common object to the client; TaxResult ?


Does that work?

 
Jay

Should that be 'newZealandStrategy(requestObject)', 'new newZealandStrategy(requestObject)', or 'new ZealandStrategy(requestObject)'? [smile]

Well, I found it mildly humerous anyway. Perhaps I need to get out more...
 
.. or even 'humorous' [smile]

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
I'm not in the US - if you consider 'color', 'thru', 'analyze' etc. to be correct, then I'll concede your point...
 
Tim

I stand corrected. I'll have to throw myself off of a stack of OEDs...
 
No Steve, don't do it. You give much too good advice on this forum to lose you to 'Death by Dictionary' [bigsmile].

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top