It is said that visitor pattern is applicable to problems where objects rarely change but we add actions on those objects more frequently.
What if the objects are changing too though? For example we might have a
NotificationSource class where it can have many children such as
SmsNotificationSource or whatever. For any incoming messaging system we might want to add another source and extend our notification system.
We can imagine actions on these models or classes may add rapidly too.
NotificationSender or whatever functionality we might define on these classes to name a few.
Using switch-cases on each of these to find which
NotificationSource object we are deadling with is discouraged and I understand why. It's not much maintainable.
Visitor pattern is not working well too because I don't like a
NotificationSender class with endless methods for each child like
handleSendingEmailNotification. I don't like the idea of adding
accept method to each of the
NotificationSource child either. I feel like it's cheating and it violates SRP (And also what is we don't have access to
NotificationSource classes? Maybe it's a installed dependency.)
I don't have any scalable (on both children and actions) and maintainable solution to this problem. Can anyone help me with this?