Board index » delphi » calculations on objects
Graeme Geldenhuys
Delphi Developer |
calculations on objects2005-06-15 05:23:09 PM delphi6 Hi The payroll application I am designing does some complicated calculations, and I need to know from a design point, what is the best (or better) method of implementing these calculations. At the momement I created a TNICalc class, to calculate National Insurance Contributions for the UK market. The calculations are done in a set of 5 steps (automatically called by the constructor), and all intermediate and final values, are available as properties as soon as I have created a TNICalcs object. In the constructor, I pass in the Employee for which the calculations must be done. I did it this way, as I didn't believe the NI Calculations belonged inside the TEmployee class. I also have the TNICalcs in a seperate unit which keeps things simple and easy for DUnit testing. The same will be done for Tax calculations. At the moment, I am only calculating one Employee at a time, but using a Vistor, I should be able to iterate through all Employees without any issues. Am I using the best design for the TEmployee and TNICalcs to work together, or is there some design pattern I could be using to get things working more smoothly? Thanks for your time. Regards - Graeme - |