What would be the way to design a system which has logic that may change year wise?There is an application which conducts online exams.There are five questions for a particular subject. The questions may (or may not) change year wise.As per my current design, the questions in database are stored year wise. There are some year specific code logic as well. In order to enable the application for another year, the year specific database records and code will be copied or duplicated. How to avoid this code duplication?
How to avoid code duplication for a system which has logic that may change year wise?
design;design patterns;architecture
Actually, I think the techniques for avoiding code duplication are the same as in any other system. For example, think about a function CalcTax2013(){...};and let's assume you have to duplicate that function for the next year (perhaps with some changes)CalcTax2014(){...};then you should immediately refactor all common parts out to a function used from both of them. Of course, you should have written some automatic tests before that to make sure refactoring does not break anything.There could be of course a different situation: when CalcTax2013 does not have to be changed later any more, lets say for example from 01/01/2014. If that's the case, there is no need for any maintenance on that function, which makes the refactoring pointless. If this does not apply to your question, please give a more elaborate example. 