Q
qazmlp1209
Requirement:
- A class has 4 members. 2 of these members are must to constitute the
concrete object.
The other 2 are optional.
What I thought of for defining interfaces to the users are:
- Provide only one version of constructor taking the 2 mandatory
members as arguments.
- Provide setters for the other 2 members.
- Provide getters for all the 4 members.
In general, it is a good style to introduce an 'interface' with all the
methods that the users require for. But unfortunately, this does not
seem to work for my above-mentioned requirements. This is due to the
reason that the class implementing the interface should provide a
constructor with empty arguments.
Can anybody suggest the best approach for such cases?
- A class has 4 members. 2 of these members are must to constitute the
concrete object.
The other 2 are optional.
What I thought of for defining interfaces to the users are:
- Provide only one version of constructor taking the 2 mandatory
members as arguments.
- Provide setters for the other 2 members.
- Provide getters for all the 4 members.
In general, it is a good style to introduce an 'interface' with all the
methods that the users require for. But unfortunately, this does not
seem to work for my above-mentioned requirements. This is due to the
reason that the class implementing the interface should provide a
constructor with empty arguments.
Can anybody suggest the best approach for such cases?