I have Multiple Profession like teachers, engineers, and scientists, etc. For each Profession, I need to do operations like getAboveSalaryPeople, getBelowSalaryPeople, getBetweenSalaryPeople.
So I implemented a strategy pattern and created a concrete class XXXAboveSalaryPeople,XXXBelowSalaryPeople,XXXBetweenSalaryPeople for each Profession. So I have a total of 9 Concrete classes.
But in the future, I can have even more Professions. So every time I add a new profession, I have to create three more classes.
So I want a better design pattern so that I don't need to create so many classes. And I don't want to create convert each getXXXsalaryPeople into a method and make a single profession class that contains methods all getXXXsalaryPeople because in the future I can have a requirement as "getRichsalaryPeople" and then I don't want to modify my single class for each profession.
Thanks in Advance.
Aucun commentaire:
Enregistrer un commentaire