S
Steven Blair
I have encountered this problem a few times and would like to see how
other people deal with it.
A library has a Constructor that takes in n params and does some basic
validation and populates the class member.
I then get a requirement to add another paramter in at initialisation
time so the options I have (as far as I can see) are:
1. Change the current interface with the new param(s). No duplicate code
but the existing interface is changed and can cause me backwards
compatibilty problems.
2. Create a new constructor and give the user the choice. Problem is the
code in Constructor one must be copied in here as the same
initialisation is required.
3. I don't allow the user to pass in the new params. I simply make a
public member (or a get/set) and hope the user picks this up.
4. Create a base constructor common to all constructors.
This involves another class but might be the best solution.
The base constructor has all the standard validation I need, and the
child classes have the specific params validation etc.
Interested to hear other peoples views on this.
Regards,
Steven
other people deal with it.
A library has a Constructor that takes in n params and does some basic
validation and populates the class member.
I then get a requirement to add another paramter in at initialisation
time so the options I have (as far as I can see) are:
1. Change the current interface with the new param(s). No duplicate code
but the existing interface is changed and can cause me backwards
compatibilty problems.
2. Create a new constructor and give the user the choice. Problem is the
code in Constructor one must be copied in here as the same
initialisation is required.
3. I don't allow the user to pass in the new params. I simply make a
public member (or a get/set) and hope the user picks this up.
4. Create a base constructor common to all constructors.
This involves another class but might be the best solution.
The base constructor has all the standard validation I need, and the
child classes have the specific params validation etc.
Interested to hear other peoples views on this.
Regards,
Steven