diff --git a/README.md b/README.md index 3043f06d471f2933c5a98c71ad06b7d900d6812c..fe46a1150efc88757d9895b6186d8aec529db663 100644 --- a/README.md +++ b/README.md @@ -48,15 +48,15 @@ You can install Postman via this website: https://www.postman.com/downloads/ (You might want to use `cargo check` if you only need to verify your work without running the app.) ## Mandatory Checklists (Publisher) -- [ ] Clone https://gitlab.com/ichlaffterlalu/bambangshop to a new repository. +- [x] Clone https://gitlab.com/ichlaffterlalu/bambangshop to a new repository. - **STAGE 1: Implement models and repositories** - - [ ] Commit: `Create Subscriber model struct.` - - [ ] Commit: `Create Notification model struct.` - - [ ] Commit: `Create Subscriber database and Subscriber repository struct skeleton.` - - [ ] Commit: `Implement add function in Subscriber repository.` - - [ ] Commit: `Implement list_all function in Subscriber repository.` - - [ ] Commit: `Implement delete function in Subscriber repository.` - - [ ] Write answers of your learning module's "Reflection Publisher-1" questions in this README. + - [x] Commit: `Create Subscriber model struct.` + - [x] Commit: `Create Notification model struct.` + - [x] Commit: `Create Subscriber database and Subscriber repository struct skeleton.` + - [x] Commit: `Implement add function in Subscriber repository.` + - [x] Commit: `Implement list_all function in Subscriber repository.` + - [x] Commit: `Implement delete function in Subscriber repository.` + - [x] Write answers of your learning module's "Reflection Publisher-1" questions in this README. - **STAGE 2: Implement services and controllers** - [ ] Commit: `Create Notification service struct skeleton.` - [ ] Commit: `Implement subscribe function in Notification service.` @@ -78,6 +78,16 @@ This is the place for you to write reflections: #### Reflection Publisher-1 +1. **Is an interface (or trait) needed in BambangShop, or a single Model struct is enough?** + In the Observer design pattern, an interface (trait) is typically used to define a contract for the `Subscriber` to ensure that all subscribers implement the required methods, such as `update`. However, in this case, we only have one type of `Subscriber` and no plans to extend it with different behaviors, so a single Model struct might suffice. Using a trait would be more beneficial if we anticipate having multiple types of subscribers with varying implementations of the `update` method. + +2. **Is using Vec (list) sufficient or is DashMap (map/dictionary) necessary for unique `id` in Program and `url` in Subscriber?** + Using a `Vec` would require additional step to ensure uniqueness, such as iterating through the list to check for duplicates before adding a new item, which can be inefficient as the list grows. On the other hand, `DashMap` inherently enforces uniqueness of keys and provides efficient lookups, making it a better choice for managing unique `id` and `url` values. Moreover, `DashMap` is thread-safe, which is crucial in a concurrent environment. + +3. **Do we still need DashMap or can we implement Singleton pattern instead for the List of Subscribers (SUBSCRIBERS)?** + The Singleton pattern ensures a single instance of a resource, but it does not inherently provide thread safety. On the other had, `DashMap` is specifically designed for thread-safe concurrent access to a map-like structure. Using `DashMap` simplifies the implementation of thread-safe data structure and reduces the risk of concurrency issues. Therefore, `DashMap` is a more practical choice for this case. + + #### Reflection Publisher-2 #### Reflection Publisher-3