No video

3. Observer Design Pattern Explanation, Walmart Design Interview Question, 2022 | LLD System Design

  Рет қаралды 112,580

Concept && Coding - by Shrayansh

Concept && Coding - by Shrayansh

Күн бұрын

Hi, in this video we have covered Observer design patter out of many design pattern which is asked in Low level system design interview.
➡️ Become a Member: / @conceptandcoding

Пікірлер: 474
@NeverGiveUp186
@NeverGiveUp186 Жыл бұрын
This is the first LLD video where I saw real coding example.. and not just theory. Great work man!! Keep it up !!
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks 🙏
@motivational_journey__
@motivational_journey__ Жыл бұрын
@@ConceptandCoding please share notes of videos
@yogeshshukla6097
@yogeshshukla6097 5 ай бұрын
@@ConceptandCodingplease can you share github or notes that is the only lacking point
@vortexgamingtv0
@vortexgamingtv0 10 ай бұрын
at 32:41 , the reason for not notifying again is that, in the implementation of obj.setStockCount(newStockCount) { stockCount = stockCount + newStockCount } not { stockCount = newStockCount }
@runtime379
@runtime379 Жыл бұрын
As a fresher , Started learning LLD from today. Enjoying the concept .so simple explanation and easy to understand Thanks bhaiya
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@adhrit1426
@adhrit1426 8 ай бұрын
For the notify function in observable concrete class, we can call the update of observer and send the current object in parameter. In the observer class, we don't necessarily have to use instance of operator in conditionals, if getData() is there in the observable interface, then we can directly use observable.getData() and it is fine. No need for constructor injection as well
@swayamprakashsahoo9002
@swayamprakashsahoo9002 5 ай бұрын
Exactly. This code will be lengthy when observer will observe multiple observable objects. So better to pass observable object through update parameter.
@msingla135
@msingla135 5 ай бұрын
Was thinking the same. Why not pass the object of current concrete class to update instead of interface.
@ankitgoyal8556
@ankitgoyal8556 5 ай бұрын
My though process: Assume you are passing object in update() Method: update(Object obj) 1) Check if this obj is null or not 2) Check if this is object of Observable or not 3) Then have to perform typeCasting, multiple checks if multiple child of ObservableInterface. Simply we can't do obj.getData() because obj can be null or of any other type. Better use constructor injection approach. I might be wrong.
@omkarjoshi3750
@omkarjoshi3750 5 ай бұрын
@@ankitgoyal8556 good point, what if we pass null. solution-> you can return without doing anything with just one if condition. 2. Why do we need to check if object is of type Observable or not, if we are expecting a variable of type Observable then how can other type can come. if someone tries this, then code will give compilation error 3. type casting is not needed. we can directly call obj.getData()
@utkarshjaiswal7224
@utkarshjaiswal7224 4 ай бұрын
According to my understanding, we don't need both the things neither constructor injection nor passing the current object, We are already adding the observer in iphone observable, why we need to differentiate it
@krutikadave4534
@krutikadave4534 Ай бұрын
Recently i started reading Head First II edition, I come back to your examples after going through each chapter. Thanks a lot for knowledge. It's really helpful.
@parasmyname784
@parasmyname784 Жыл бұрын
Just brilliant, You are giving us true insight into enterprise level coding,, thanks a lot
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@agunnik8
@agunnik8 Жыл бұрын
Happy to be here before this channel blows up. Keep up the quality content.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
welcome
@gyandeepdigra8461
@gyandeepdigra8461 9 ай бұрын
bought Gaurav Sen's course but you explain better than him. I saw only 1 video from his playlist and will watch all ur videos. Keep up bro..
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
Hi Guys, how was the explanation? Please let me know where i can improve. like voice speed and clarity, depth of topic detail, handwriting, example taken etc.
@neha6000
@neha6000 2 жыл бұрын
Aap ne bahoot achha video banaya hain
@gurdevrana5917
@gurdevrana5917 2 жыл бұрын
It was really amazing. Thanks a lot. Keep up the good work.
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
@@gurdevrana5917 thanks a ton
@aashishgoyal1436
@aashishgoyal1436 2 жыл бұрын
top notch
@abhaytiwari1615
@abhaytiwari1615 2 жыл бұрын
Insanely awesome explanation!! Loved it.
@omtiwari2387
@omtiwari2387 3 ай бұрын
Very nice explaination. In the Observable concrete class, you should first update the stocks value and then call update for the observers. Reason: It might happen that the update method in Observer has something to do with the number of stocks currently available. It will get the old value not the updated one.
@srijonroy7084
@srijonroy7084 9 ай бұрын
Simple and brilliant explanation. Particularly good for those who is revising and have some idea
@ConceptandCoding
@ConceptandCoding 9 ай бұрын
Thanks
@mahabaligowda6925
@mahabaligowda6925 Ай бұрын
Hi Shrayansh, Your amazing man, I have reviewed Java and DP's. Now i am fan of you. you make concept simple, understandable and moreover easy to remember, Thanks for your hard work man. you have great future. For sure we see more video's going forward.
@snehilsinha4689
@snehilsinha4689 Жыл бұрын
I think that in the setStockCount() method, we should do stockCount = newStockAdded instead of stockCount+=newStockAdded since let's say we want to make the stock as 0 as in 32:42, the stockCount will stay 10 itself as 10+0 = 10. That's the reason why it didn't notify second time. Please correct me if I am mistaken somewhere while understanding this. Thanks.
@dhanbahadurchhettri2712
@dhanbahadurchhettri2712 Жыл бұрын
Yes I was also thinking why it didn't print twice
@wul_frik
@wul_frik Жыл бұрын
I think it's better if we keep the setStockCount() as such and add another method addStockCount() which will notify subscribers. Another thing is we have to add the stocks before notifying the subscribers if we want to get the new stockCount from the observable in update() method.
@tanmaya2421
@tanmaya2421 Жыл бұрын
stockCount+=newStockAdded is correct. Let's say stockcount = 5, then we add 100 new stocks, so stockcount becomes 105. But if we use stockCount = newStockAdded, then it will give incorrect stock count (in this case 100 instead of 105 ).
@ishaansrivastav5732
@ishaansrivastav5732 Жыл бұрын
@@tanmaya2421 True, but then for the example he gave when he set stock count to 0, he should have reduced the stock count with -10
@ranitganai2725
@ranitganai2725 7 ай бұрын
Yes , it should have printed twice but it didn't because stockCount is set to 0 for once only, after that stockCount is getting updated everytime resulting notify method not getting executed.
@danishmichael6953
@danishmichael6953 2 ай бұрын
An Observer can register with multiple Observables. If we use constructor injection, then we are limited to only one Observable implementation which is usually not the case.
@vipintripathi5362
@vipintripathi5362 11 күн бұрын
Yeah, I think same.
@handlenotavailable538
@handlenotavailable538 Жыл бұрын
just joined the channel for lld, hld and java videos, great content bro, worth the money 😃
@ConceptandCoding
@ConceptandCoding Жыл бұрын
:) thanks a lot
@dhvanilvadher1356
@dhvanilvadher1356 5 ай бұрын
Thank you @Shreyansh ! I have never found a better Design pattern video.
@ConceptandCoding
@ConceptandCoding 5 ай бұрын
thanks
@deepakkedia3881
@deepakkedia3881 2 жыл бұрын
nicely explained Shrayansh. Hope to get more videos on LLD.
@mannusharma3228
@mannusharma3228 2 ай бұрын
Hats off to your explanation buddy.... big fan of your teaching 😊
@GlynesDsouza-zb8pq
@GlynesDsouza-zb8pq Жыл бұрын
Too good.... This level of depth in knowledge covered with such simplicity..... Its phenomenal. Thank you so much and keep the good work up
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@eshwarsai5027
@eshwarsai5027 3 ай бұрын
Man! You are really killing in teaching the concepts❤️.
@ayushijain2911
@ayushijain2911 2 жыл бұрын
One of the best explanation on youtube. Thanks
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
thanks Ayushi 🙂
@harshmangal6576
@harshmangal6576 5 ай бұрын
Amazing simple explanation i have never seen such a simple explanation keep it up 😊
@ConceptandCoding
@ConceptandCoding 5 ай бұрын
thanks
@namanjain2488
@namanjain2488 11 ай бұрын
observal -> state changes. observer -> state changes of observable observed by observer make there interface where there can be many observer but single observable and make there classes In observable class u will make a list of observer , u will add observer, remove objserver , notify all observer , and change the state of data or get the state of data.
@abirpaul9027
@abirpaul9027 8 ай бұрын
the best teacher for lld
@ConceptandCoding
@ConceptandCoding 8 ай бұрын
Thanks 🙏
@ParomitaDeSarkar
@ParomitaDeSarkar Жыл бұрын
Thankyou for this video. The mixture of the question and the explanation pattern together, will help me to remember this kind of scenario well. Thankyou once again!
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks 🙏
@Seekplay883
@Seekplay883 Жыл бұрын
Simple and crispy explanation, hats-off to you
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks a lot 🙏
@shatrudhankumar7824
@shatrudhankumar7824 6 ай бұрын
Why i found your video so late ?Anyway, You make things easier then what people used to complex it.
@ConceptandCoding
@ConceptandCoding 6 ай бұрын
thanks for the feedback
@kapilgyanchandani
@kapilgyanchandani 4 ай бұрын
Very good explanation with examples, Thanks a lot for such videos.
@mohitladia
@mohitladia Жыл бұрын
Loved the real-time scenario
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@nishantkumar6116
@nishantkumar6116 Жыл бұрын
Very Nice Explanation. Please keep on adding new videos on these topics
@ConceptandCoding
@ConceptandCoding Жыл бұрын
thank you
@anirbandutta2266
@anirbandutta2266 2 ай бұрын
Well explained, you gave a good clarity of the concept, easy to remember + revise.
@abhaytiwari1615
@abhaytiwari1615 2 жыл бұрын
Hi Shrayansh, wouldn't there be need of initializing many objects if there are many obervable for a single observer...dependency injection in method update will be better right? THen both of them become loosely coupled, and anyway since the method are from interface we can call it using the interface argument......eg could be like 1 user can call notify on multiple items..so in that case it becomes m:n relation.. pls correct me if i am missing something
@soumalyasahoo2664
@soumalyasahoo2664 Жыл бұрын
can you give another example where the observer has multiple observable? In this case i think instead of having a observable object inside the observer , we might need to have concrete objects as task that the observer will perform after geting the data from the observable(s) might depend on the type of the observable. For example: if the observable is temperature increase , the observer will lower the temperature , and if another observable is item in stock notification , the observer will place a order for that item. Or if we follow what you said in this video , where i dont have to check the type of observable , then i might need to make differnt types of observer Example : TempObserver, StockObserver
@sourabhchoudhary7289
@sourabhchoudhary7289 Жыл бұрын
Not sure if you are talking about an observer having multiple observables at the same time(eg, the App have footballScoreObservable, cricketScoreObservable, etc) or an observer having multiple observable at diff times(eg, we switch to a different page so now we will have a footballScoreObservable and another page will have cricketScoreObservable. Both footballScoreObservable and cricketScoreObservable will implement a common interface, so it's like a strategy pattern where we select Observable at runtime.
@adhrit1426
@adhrit1426 8 ай бұрын
If you have a observer subscribed to multiple observables(eg weather station and stock market), then it's better not to use constructor injection. Just add this observer to both WeatherStation and Stock market and whenever any one of them changes, the observer will be notified. If you use constructor injection, then that means you have kind of hardwired which type of observable this user wants, so multiple subscription for same observer object will fail.
@anuragv400
@anuragv400 Жыл бұрын
Great explanation man! It was really helpful
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@ishanpatil6294
@ishanpatil6294 Жыл бұрын
Question 1 : In case of more then one observable in a single observer, wouldn't you still have to check which observable called the update method? resulting in some if/else again inside update(). Question 2 : If we don't send the data in update(), won't the update logic loose on some data in case of race condition? (say temperature updates few times in a row, and since instead of passing the temperature value we are passing observable object which will have updated data always.)
@abhishekmahajan17
@abhishekmahajan17 Жыл бұрын
It will be better if we send the observable object in update method. You have found the loopholes
@aravindkumarn1776
@aravindkumarn1776 Жыл бұрын
Buddy it's easy to add caption for old videos. Just edit your video in KZfaq studio and select English in caption drop-down and then click save/submit changes. It will take sometimes to add caption automatically to your video.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
No buddy it's not working, hindi to English caption is not working. It want me to type each line which I am saying in hindi. There are certain language for which auto caption is available and hindi is not one of it.
@aravindkumarn1776
@aravindkumarn1776 Жыл бұрын
@@ConceptandCoding Oh okay buddy. If possible could you please create playlists for spring boot if possible. You really good teacher nice content creator that's why I am giving my suggestion
@mahendrapatidar7416
@mahendrapatidar7416 Жыл бұрын
Bhai kya explain krte ho yr, maja aa gya. I love you.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you 🙂
@dheeraj5531
@dheeraj5531 Жыл бұрын
Nicely explained everything ❤
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@sagar1691
@sagar1691 7 ай бұрын
Again very well explained , And yes it will be nice if you explain Implementation With PropertyChangeListener which is another way to implement this.
@jaymanik
@jaymanik Жыл бұрын
Thank you for the detailed video. Very good explaination.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@vishalsharma8432
@vishalsharma8432 Жыл бұрын
Hi Shrayansh, thanku for this amazing tutorial.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks 👍
@shardulsant4726
@shardulsant4726 Жыл бұрын
Why can't you pass 'this' (instance of WSObservable) in the update instead of constructor injection. You can then call whatever methods on that like you did with constructor instantiated object.
@umangmalhotra1222
@umangmalhotra1222 Жыл бұрын
While notifying observers, we should do the same in an asynchronous manner.
@jinendrajain7672
@jinendrajain7672 Жыл бұрын
Greate work, Huge respect for you bro.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@sameer9368
@sameer9368 Жыл бұрын
Awesome Explanation♥
@neha6000
@neha6000 2 жыл бұрын
Bahoot hi achha explanation
@sameerchoudhary8590
@sameerchoudhary8590 6 ай бұрын
Very crisp and clear explanation.
@vikashkumarchaurasia1299
@vikashkumarchaurasia1299 Жыл бұрын
🎉🎉🎉 perfect explaination
@aksharbrahm4618
@aksharbrahm4618 2 ай бұрын
It was good ..one suggestion .. Koi ek hi language me poora video banaiye ..Kabhi kabhi aap english me switch ho jate ho ..HIndi me hi rakhiye
@mohitthakur5571
@mohitthakur5571 2 жыл бұрын
Good stuff Shrayansh. Keep them coming
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
thank you
@dileepkumareduvaka4864
@dileepkumareduvaka4864 Ай бұрын
excellent work man, this is really good, telling theoretically is one thing, but writing actual code is another thing. But i have a doubt, could you suggest anything to C++ people, because syntax may differ and its difficult.
@aadhaarbhatia2759
@aadhaarbhatia2759 6 ай бұрын
Great one!! I could not understand the part where it was mentioned that we would have had to use "instanceof" if we were not doing constructor injection. Please add some clarity on that part. Some example would be great!!
@paritoshdadhich2954
@paritoshdadhich2954 11 ай бұрын
Thanks for the wonderful explanation
@rajdave7357
@rajdave7357 Жыл бұрын
Sir sach bolu Maja aagaya ❤❤❤❤
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@gauravsharma4532
@gauravsharma4532 Жыл бұрын
Perfect , to the point explanation. Keep posting vedios👏
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@nikhilupadhyay2199
@nikhilupadhyay2199 Жыл бұрын
Sir I am just starting to watching your video. Please Sir make more it'll help us
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Sure, yes lot of videos already uploaded and next will come on Sunday
@shubhamagarwal1434
@shubhamagarwal1434 2 ай бұрын
Very well explained...awsome!!!
@ashwani6360
@ashwani6360 Ай бұрын
we should use set to store all the observers in the observable class
@jagritbhupal5836
@jagritbhupal5836 Ай бұрын
Amazing video, Thank you!
@patrisrikanth
@patrisrikanth 7 ай бұрын
Awesome Explanation ...
@ConceptandCoding
@ConceptandCoding 7 ай бұрын
thanks
@satish7931
@satish7931 4 ай бұрын
Thanks for the video!! Having both Setdata Getdata methods inside Observable class seem to violate Single responsibility principle. Now this class is responsible for both notifying as well as managing the data. May be better to seperate the data managing part to seperate interface and take it as input to observable class
@geekydanish5990
@geekydanish5990 2 жыл бұрын
I think thats the perfect example of how a High Level design model such as pub-sub is translated into a low level Observer pattern, I think for each hld there must exisits some corresponding lld pattern that's my hypothesis 😬
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
this is a topic of discussion 😊😊 i cannot say as i am not sure
@saivasanth8819
@saivasanth8819 Жыл бұрын
Hi Danish, there is a slight difference here, In the observer pattern, the observable and observer know each other, but in the pub-sub model, the publisher and consumer will not know each other, they will communicate through the queue. So, this is where both will get vary, but the concept of notifying is same, hope you got the clarity :)
@harshinredzone
@harshinredzone Жыл бұрын
in my opinion, pub sub is still observer. It's only one level abstraction. Instead of them interacting directly, they have agents to take care of it in pub sub.
@LifeDude
@LifeDude 2 ай бұрын
Kind of same. Where pub sub messages are preserved where as here fire and forgot no events are kept
@myaccount09011975
@myaccount09011975 Ай бұрын
Thanks Shrayahsh for this video. In case of multiple customers registering for 1000 products on Amazon, I believe we will not create multiple observers for each product right. How can we accommodate this requirement? How will it work in case of Distributed setup where entire scenario is handled by different microservices. We need a distributed Notification mechanism, right? I believe pubs/subs or event messages may be good option here.
@prakashshindalkar6959
@prakashshindalkar6959 2 жыл бұрын
very good explanation. Thank you
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
thank you
@nishanthmekala1409
@nishanthmekala1409 Жыл бұрын
Your videos are awesome. But I would like to know the below things 1. which one we should start first hld or lld? 2. In what way we should learn hld and lld? 3. How to practice these and gain hands on experiene? 4. Is it necessary to take a course after watching your videos? 5. Any order, you would reccomment to follow? Please clear my doubts Shreyansh.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Both can be learn in parallel. If exp less than 2yr. LLD can be done first else both can be done in parallel
@aashishgoyal1436
@aashishgoyal1436 2 жыл бұрын
very nicely explained.Keep it up
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
thank you
@Newbie789
@Newbie789 Жыл бұрын
great explanation, thank you so much for making this kind of video.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@kanchankatkar5226
@kanchankatkar5226 13 күн бұрын
You explained very well, thanks for your content. just one thing can I get code repo to go through it. or can I download it from somewhere?
@terminator8397
@terminator8397 Жыл бұрын
In case of multiple observables, do you end up writing different update methods in the observer class. Checking instance of gets replaced with new method strongly tied to one of the observable. Am I missing something here?
@rpatil1169
@rpatil1169 Жыл бұрын
Great Explanation
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@iWontFakeIt
@iWontFakeIt 6 ай бұрын
excellent explanation!
@ConceptandCoding
@ConceptandCoding 6 ай бұрын
thanks
@swayamprakashsahoo9002
@swayamprakashsahoo9002 2 ай бұрын
Interviewer : Now scale it for multiple products
@prashantgupta6160
@prashantgupta6160 Жыл бұрын
Hey, Shreyansh, nicely explained, but I do have one question. Q1. we are designing this notify me service for amazon, amazon has lot of products, will each product be creating one concrete observable? or there will be single observable that keeps the record of subscribers for all the product in the form of map of arrays where key is product id and array is list of subscribers and when writing notify it will take product id and notify the respective subscriber. Q2. we are saying concrete observer will have instance of concreate observable, what to do, if I want to observe multiple products from Amazon?
@sourabhchoudhary7289
@sourabhchoudhary7289 Жыл бұрын
we are saying concrete observers will have instances of concrete observable, what to do if I want to observe multiple products from Amazon? I think here sending the observable object to the observer.update(obj) will be a good option as multiple observables can send the update event and then we have to figure out which instance called it using instanceof. As even if maintain a list of observables in observer it will not solve our problem as we still have to figure out which observable triggered the update event. hope it make sense, and correct me if I am wrong :)
@anantsingh2004
@anantsingh2004 Жыл бұрын
in the update method firstly the count should be set and then if (count != 0) notifySubscribers can be called.
@AdityaSingh-pj7kw
@AdityaSingh-pj7kw 2 ай бұрын
Hey Shrayansh Can you please provide access to the notes and code used in the video? Keep up the great work!!
@pawan0209
@pawan0209 Жыл бұрын
Great explanation 👍🏻
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@naveenam6322
@naveenam6322 Жыл бұрын
It definitely helps if this is taught in English. who doesn't know Hindi
@ConceptandCoding
@ConceptandCoding Жыл бұрын
I have covered it's English version Live LLD Sessions: kzfaq.info/sun/PL6W8uoQQ2c63ODkc0LVNiZtVX4vrsO3iO
@naveenam6322
@naveenam6322 Жыл бұрын
@@ConceptandCoding thank you
@anirudhsingh7832
@anirudhsingh7832 7 ай бұрын
Good Video. Thanks man.
@mohammadkaif8143
@mohammadkaif8143 Жыл бұрын
Awesome Content
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks for
@user-cy8fj7xx1n
@user-cy8fj7xx1n 4 ай бұрын
Great video
@ripanpramanick425
@ripanpramanick425 Жыл бұрын
We can take List in the WSObservable Interface as whenever we will be adding data from our concrete class we can add object to final list as we are not reassaigning new list object but only afding object to final list
@adhrit1426
@adhrit1426 8 ай бұрын
Even if you do so, the list will be public, static and final like you said. But the think is if we have two observables, like WeatherStation and CricketScoreUpdate, then whenever you add something for weather station, it will reflect for cricket score update as well, which in most cases is not fine, since observable will have their own observers, they won't necessarily share observers. You add for observable 1, by default will get added to all the observables
@sunitajoshi902
@sunitajoshi902 Жыл бұрын
Great work man..
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@sahildadhich59
@sahildadhich59 2 ай бұрын
very nice
@AnupSingh-hd5ck
@AnupSingh-hd5ck Жыл бұрын
I understand the observer pattern but what if the application goes down or somehow we lost the stored information(observers) ? in this scenerio how will get the data back ? of course we need to store these information in db. but if it`s in the db then what is the purpose of observer pattern ? we can simple query the db and do the stuff (querying again and again is not good approach ) so can you or anyone explain this to get better understanding about this.
@ravikumar-gp6ui
@ravikumar-gp6ui Жыл бұрын
Amazing explanation. nice video
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Glad you liked it
@AtharvaRao0104
@AtharvaRao0104 Жыл бұрын
In the concrete observer, we inject concrete observable in the constructor so that we can get the updated state from this concrete observable when a notification comes. But I also think the concrete observer needs that observable to subscribe (register) itself. Right?
@shubhshah4192
@shubhshah4192 11 ай бұрын
Yes
@user-ft6sh1wx6j
@user-ft6sh1wx6j Ай бұрын
Second wale case if we do setStock(100) then it adds to previous count of 10 hence we are not seeing it twice
@muskan_bagrecha
@muskan_bagrecha Ай бұрын
Shouldn't we have a single observable class which can handle multiple products identified by their ID? Then we can pass this object to the observer and observer will check if it is not null then it can perform some action, so no need of contructor injection also. Please correct me if i am wrong.
@SyedaTabassum.
@SyedaTabassum. 23 күн бұрын
1. Can we consider Linkedin Job alert feature as Observer Design Pattern,? 2. Can we get code repository link for all these design patterns, would be helpfull for revision?
@engineer_jaatni
@engineer_jaatni Жыл бұрын
Really Helpful!
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@syedsheheryarumair97
@syedsheheryarumair97 3 ай бұрын
Very informative video! I have a question that suppose if my store has 100 products apart from iPhone. I would have to create 100 concrete classes for it?
@PrateekSaini
@PrateekSaini 6 ай бұрын
If we keep an instance of Observable in Observer then I can call setData also. It's better to use a Notification object and pass it to the update method. This Notification object will contain all the necessary information.
@bhavesh25shah
@bhavesh25shah 2 ай бұрын
In the example, I can see that there is a dependency of Observer interface in Observable interface and vice versa. I don't understand one thing how the dependency will get resolved? Will it end up in cyclic dependency? Can you please help explaining it? Which object will get created first and how?
@weirdstrategist
@weirdstrategist 2 ай бұрын
a doubt here , can't this be solved by the following strategy : 1. Use a single table with a composite key (product_id, user_id) to store user subscriptions.The users will be added to based on the endpoint for notify users. 2. When stock becomes available, a Kafka event is triggered. 3. A dedicated service consumes Kafka events and queries the centralized table for users subscribed to the specific product. 4. Users are then notified based on a separate endpoint. Doesnt this eliminates the need for observer pattern here
@dhirajrana397
@dhirajrana397 Ай бұрын
For a observer having multiple obervers: List observableList, in update method how do we find which data in observer to be updated / what action to be performed ?
@dakshtaneja9189
@dakshtaneja9189 Жыл бұрын
Hey I have a doubt here: if we are creating iphone object and passing it in the constructor of observer i.e - email or mobileAlert. then still it is not becoming that dynamic like in a system of 1000 products do we need to create 1000 objects of each product and then pass it in the observer constructor. Need to know how we can make it dynamic when the system is large or there are multiple products.
@newgusern7184
@newgusern7184 Жыл бұрын
Same doubt
@akshaymahajan9626
@akshaymahajan9626 6 ай бұрын
very good
@ConceptandCoding
@ConceptandCoding 6 ай бұрын
thanks
@Lucifer-dd1zn
@Lucifer-dd1zn 3 ай бұрын
Hey, lets say if there is a observer concrete class listening to 3 different observables, [video time : 12:55] 1. How will we inject 3 different objects of observables [for eg if a single customer says notify me for 3 different products at different times] in the observers class ? 2. Even if we can lets says we maintain a List in Observer, we still would need to go through all of them to know which one has actually changed. So how is Observer keeping an object / list of Observable/ Observables helping ? Basically whats the best solution in that case ?
@adarshdivya4883
@adarshdivya4883 Жыл бұрын
Hindi me zaada ache se samjh me aata hai humlog zaada ache se connect kar paate hai
@aditya.chavda
@aditya.chavda Жыл бұрын
Wouldn’t it be better if you just pass the data directly from Observable as parameter to the update method of Observer? Cause having the object of Observable in a Observer is unnecessary I think. Wouldn’t having so also expose all the other methods (like add, remove, setData, etc) of the Observable to the Observer?
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Yes we can. Let's understand what things we need to consider if we want to pass the data as parameters: - Scenario1: Pass all the different parameters which are required by Observer, but problem with that is, number of parameters size become big. - Scenario 2: Observer should expose the POJO, in which observable class fills the data and send. But problem with that is why Observable takes the responsibility to fill the pojo. - Scenario 3 : Observer have Observable object, problem with that is " which you raised" All we can go with different ways all has some pros and cons, and we can choose based on situation. Hope that clarifies
الذرة أنقذت حياتي🌽😱
00:27
Cool Tool SHORTS Arabic
Рет қаралды 14 МЛН
Look at two different videos 😁 @karina-kola
00:11
Andrey Grechka
Рет қаралды 14 МЛН
小丑把天使丢游泳池里#short #angel #clown
00:15
Super Beauty team
Рет қаралды 43 МЛН
CHOCKY MILK.. 🤣 #shorts
00:20
Savage Vlogs
Рет қаралды 29 МЛН
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 250 М.
Mock Low Level System Design Interview with Qualcomm Sr. Engineer - Design Meeting Scheduler
37:23
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,2 МЛН
Design a High-Throughput Logging System | System Design
8:23
Interview Pen
Рет қаралды 44 М.
5. Factory Pattern Vs Abstract Factory Pattern Explanation, Low Level System Design interview
12:19
20 System Design Concepts Explained in 10 Minutes
11:41
NeetCode
Рет қаралды 968 М.
Observer Pattern - Design Patterns (ep 2)
49:47
Christopher Okhravi
Рет қаралды 561 М.
الذرة أنقذت حياتي🌽😱
00:27
Cool Tool SHORTS Arabic
Рет қаралды 14 МЛН