Tales of caution
Posted: Wed Oct 31, 2007 5:37 am
At the moment I am having to update some legacy code where we were getting some prices going wrong. Not a big deal once I had finally tracked the problem down but time consuming never the less.
The problem.. Some time ago the German government changed the tax on goods (mwst, VAT in england) from 16% to 19%. In some places in the legacy code this was a variable, in others it was actually base price*1.16 and yet others got the information from a database (OK admit I added this previously as we had lots of files and I wanted a single place to need to change things). The problem we were having is that a couple of places the change wasn't implemented. I have just spent time going through the code tracking down any place where this mwst is calculated and standardising it to always use the value from the database.
My tale of caution is therefore... Always allow for changes in tax and make it easily changable in just one place. Also always process it using the same method.
Does anyone else have any tales which may be of benefit to people when designing code to avoid updates to legacy code ?
Other obvious ones include ...
.. Upgrade to php5 when creating new projects rather than use php4.
.. Make sure that register_globals is off, even for php4 legacy code
.. Don't rely on short tags as another server may not recognise them
The problem.. Some time ago the German government changed the tax on goods (mwst, VAT in england) from 16% to 19%. In some places in the legacy code this was a variable, in others it was actually base price*1.16 and yet others got the information from a database (OK admit I added this previously as we had lots of files and I wanted a single place to need to change things). The problem we were having is that a couple of places the change wasn't implemented. I have just spent time going through the code tracking down any place where this mwst is calculated and standardising it to always use the value from the database.
My tale of caution is therefore... Always allow for changes in tax and make it easily changable in just one place. Also always process it using the same method.
Does anyone else have any tales which may be of benefit to people when designing code to avoid updates to legacy code ?
Other obvious ones include ...
.. Upgrade to php5 when creating new projects rather than use php4.
.. Make sure that register_globals is off, even for php4 legacy code
.. Don't rely on short tags as another server may not recognise them