In this video of code decode we have explained scenarion design pattern which can be asked by interviewer
Udemy Course Discounted Link
https://www.udemy.com/course/master-spring-boot-microservice-angular-with-k8s-cicd-aws/?couponCode=APRIL2025
Top scenario based design patterns interview question
** You have an **`**Order**`** class with many optional fields. What pattern would you use to create immutable **`**Order**`** objects efficiently?**
The `@Builder` annotation in Java (typically from **Lombok**) helps implement the **Builder Pattern** without manually writing all the boilerplate code.
### Scenario : Performance Optimization for Expensive API Calls
Your application interacts with a third-party payment gateway that charges per API call. However, some customers repeatedly request the same transaction status, even when it hasn’t changed.
- How would you design the system to reduce unnecessary API calls while still ensuring up-to-date transaction status?
- What risks exist if every request is directly forwarded to the third-party API without any intervention?
### 5. Decorator Pattern
**Scenario: You need to add caching functionality to an existing service without modifying its code. How would you achieve this?
**Answer: Scenario: Adding Caching Functionality Without Modifying Service Code
You have an existing service, and you want to add caching functionality to it, but you cannot modify the original service code. The goal is to enhance the service by introducing caching capabilities, ensuring that repeated requests don't need to recompute or re-fetch the same data, improving performance.
### Scenario: Real-Time Notifications for Stock Price Updates
Your application provides real-time stock price tracking for users. Each user can choose which stocks they want to track, and they should receive real-time updates when the stock price changes.
- How would you design the system to ensure that only the relevant users are notified when the price of a stock they are interested in changes?
- What challenges could arise if every user manually checks the stock prices at regular intervals instead of receiving updates when changes occur?
Mock Interview Playlist:
https://www.youtube.com/playlist?list=PLyHJZXNdCXsdKpIT19C1nlZH_HROXyROF
Most Asked Core Java Interview Questions and Answers: https://youtube.com/playlist?list=PLyHJZXNdCXscoyL5XEZoHHZ86_6h3GWE1
Advance Java Interview Questions and Answers: https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd
Java 8 Interview Questions and Answers:
https://youtube.com/playlist?list=PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy
Hibernate Interview Questions and Answers:
https://youtube.com/playlist?list=PLyHJZXNdCXsdC-p2186C6NO4FpadnCC_q
Spring Boot Interview Questions and Answers:
https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd
Angular Playlist:
https://www.youtube.com/watch?v=CAl7RQSdq2Q&list=PLyHJZXNdCXsfxRtDwtGkDD_lLfTWc1g0i
SQL Playlist: https://www.youtube.com/playlist?list=PLyHJZXNdCXse86eLuwy5uZohd_bddE9Ni
GIT: https://youtube.com/playlist?list=PLyHJZXNdCXscpl6pxOnL2lRWJlzvzjyZE
Subscriber and Follow Code Decode
Subscriber Code Decode: https://www.youtube.com/c/CodeDecode?sub_confirmation=1
LinkedIn : https://www.linkedin.com/in/codedecodeyoutube/
Instagram: https://www.instagram.com/codedecode25/
#jpa #codedecode #interviewquestions