diff --git a/README.md b/README.md index 69e2960b3c81f02973535cfca40c34d4681a3947..d33878db4304d9e6372f8e4b9a026d9d35b15bb6 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,11 @@ You can install Postman via this website: https://www.postman.com/downloads/ - [x] Commit: `Implement unsubscribe function in Notification controller.` - [x] Write answers of your learning module's "Reflection Publisher-2" questions in this README. - **STAGE 3: Implement notification mechanism** - - [ ] Commit: `Implement update method in Subscriber model to send notification HTTP requests.` - - [ ] Commit: `Implement notify function in Notification service to notify each Subscriber.` - - [ ] Commit: `Implement publish function in Program service and Program controller.` - - [ ] Commit: `Edit Product service methods to call notify after create/delete.` - - [ ] Write answers of your learning module's "Reflection Publisher-3" questions in this README. + - [x] Commit: `Implement update method in Subscriber model to send notification HTTP requests.` + - [x] Commit: `Implement notify function in Notification service to notify each Subscriber.` + - [x] Commit: `Implement publish function in Program service and Program controller.` + - [x] Commit: `Edit Product service methods to call notify after create/delete.` + - [x] Write answers of your learning module's "Reflection Publisher-3" questions in this README. ## Your Reflections This is the place for you to write reflections: @@ -105,6 +105,28 @@ This is the place for you to write reflections: Postman allows me to send HTTP requests to me endpoints and verify their responses. For the current project, Postman helps in testing the `Notification` and `Product` endpoints by simulating real-world API interactions. Additionally, Postman's automated testing scripts can validate response data, ensuring that the API behaves as expected. +#### Reflection Publisher-3 +1. **Which variation of Observer Pattern do we use in this tutorial?** + + In this tutorial case, we use the Push model of the Observer Pattern. The publisher (BambangShop) actively sends notifications to the subscribers whenever an event occurs, such as the creation, deletion, or promotion of a product. + +2. **What are the advantages and disadvantages of pull model of Observer Pattern for this tutorial?** + + If we were to use the Pull model instead, advantages include: + - Subscribers have more control over when and how they retrieve data, reducing unnecessary notifications. + - It can be more efficient if subscribers only need updates occasionally or under specific conditions. + + However, the disadvantages include: + - Increased complexity for subscribers, as they need to implement logic to periodically check for updates. + - Potential delays in receiving updates, as subscribers might not pull data immediately after an event occurs. + - Higher risk of missing critical updates if the subscriber fails to pull data in time. + +3. **What will happen to the program if we decide to not use multi-threading in the notification process?** + + If we do not use multi-threading, then the program will handle notifications sequentially. which means: + + - The main thread will be blocked while sending notifications, potentially causing long delays in other requests. + - The overall performance of the application will degrade significantly, especially if there are many subscribers or if the notification process involves network latency. + - Application could become unresponsive during the notification process. -#### Reflection Publisher-3