I understand that factory pattern is about creation and strategy pattern is about behavior, but I found both pattern seem to be ok in my situation. I am hoping if someone could point out any potential difference in my situation.
I need to create a ScheduleService, which consist of several pattern such as hourly, daily, monthly, and irregular. One way to do this is strategy pattern where I create a interface and implement it with classes for each pattern.
I think I also can use factory pattern along with enum for each pattern. The factory pattern could takes in this enum and construct the schedule object with different member variable. Basically I could use the same method with different member variable to do the computation.
Please comment on these two design, I would like to have some feedback. thanks.
Aucun commentaire:
Enregistrer un commentaire