Reputation: 4074
If was going through a C# exam book and I read:
A popular design pattern (a reusable solution for a recurring problem) in application development is that of publish-subscribe. You can subscribe to an event and then you are notified when the publisher of the event raises a new event. This is used to establish loose coupling between components in an application.
It got me wondering that what does this have to do with loose coupling? Is it only because the components are now not interacting directly or do we have more reasons?
Upvotes: 0
Views: 323
Reputation: 161
There are 2 important points in this .
1) user don't need to wait for the result or fire a event like click or refresh to get the changes this decouples the event source form front end to back end
2) I am not sure you will do this but event sourcing is broadly used in publish subscriptions mechanism and this will allow you decople domain entity alot
Ex . Employ salary credited will also trigger an event for creating a pay slip which will add the pdf on pay slip page of employee and send mail without employees salary This will decouple employee from pay slip generate service, and mailing also . And also update the UI for end user
Upvotes: 1