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

  Рет қаралды 122,706

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

Пікірлер: 495
@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.
@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
@krutikadave4534
@krutikadave4534 2 ай бұрын
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.
@vortexgamingtv0
@vortexgamingtv0 11 ай бұрын
at 32:41 , the reason for not notifying again is that, in the implementation of obj.setStockCount(newStockCount) { stockCount = stockCount + newStockCount } not { stockCount = newStockCount }
@SatyamRaj-lf8bi
@SatyamRaj-lf8bi Ай бұрын
Yeah,thanks !
@shirinjain2994
@shirinjain2994 5 күн бұрын
thanks
@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 7 ай бұрын
@@ConceptandCodingplease can you share github or notes that is the only lacking point
@parasmyname784
@parasmyname784 Жыл бұрын
Just brilliant, You are giving us true insight into enterprise level coding,, thanks a lot
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@gyandeepdigra8461
@gyandeepdigra8461 10 ай бұрын
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..
@mahabaligowda6925
@mahabaligowda6925 2 ай бұрын
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.
@srijonroy7084
@srijonroy7084 10 ай бұрын
Simple and brilliant explanation. Particularly good for those who is revising and have some idea
@ConceptandCoding
@ConceptandCoding 10 ай бұрын
Thanks
@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 8 ай бұрын
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.
@handlenotavailable538
@handlenotavailable538 Жыл бұрын
just joined the channel for lld, hld and java videos, great content bro, worth the money 😃
@ConceptandCoding
@ConceptandCoding Жыл бұрын
:) thanks a lot
@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
@danishmichael6953
@danishmichael6953 3 ай бұрын
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 Ай бұрын
Yeah, I think same.
@sagar1691
@sagar1691 8 ай бұрын
Again very well explained , And yes it will be nice if you explain Implementation With PropertyChangeListener which is another way to implement this.
@namanjain2488
@namanjain2488 Жыл бұрын
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.
@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
@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
@shatrudhankumar7824
@shatrudhankumar7824 7 ай бұрын
Why i found your video so late ?Anyway, You make things easier then what people used to complex it.
@ConceptandCoding
@ConceptandCoding 7 ай бұрын
thanks for the feedback
@aravindkumarn1776
@aravindkumarn1776 Жыл бұрын
Buddy it's easy to add caption for old videos. Just edit your video in KZbin 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
@harshmangal6576
@harshmangal6576 6 ай бұрын
Amazing simple explanation i have never seen such a simple explanation keep it up 😊
@ConceptandCoding
@ConceptandCoding 6 ай бұрын
thanks
@vasans7314
@vasans7314 27 күн бұрын
Thanks for the great explanation. The example which used here is perfectly making sense to understand observer pattern. But I feel like its not the optimal solution for the interview question, I mean keeping the Observable tightly coupled with Observer. Because in real world scenario, we wont be having observer as a separate class for each product ? It will be simply called as product and the Observers mostly created in such a generic way which means it should be used for any products (not only iPhone). Your reason includes that "isinstance" is not a perfect check (which I agree), but if it includes such check then its a not perfect solution right ?. So I feel like observable.update() should accept product parameter and whatever the product you just notify them :) Any thoughts ??
@dhameliyayagnik4236
@dhameliyayagnik4236 26 күн бұрын
at 22:10, you are using constructor injection at observer side for getting object of observable that means for a observer there can be only one observable(Say, vishal is registering to notified when IPhone are in stock). So, the issue of (O is Instance of ...) has been resolved as there can be only one observable object using this that, you can pass each object of observable in "update" with type of object for passing is is "observableInterface". I know, May be i am misunderstanding something but as of now this is what i understood. Please resolve this doubt and explain how things are working.
@aksharbrahm4618
@aksharbrahm4618 3 ай бұрын
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
@kapilgyanchandani
@kapilgyanchandani 5 ай бұрын
Very good explanation with examples, Thanks a lot for such videos.
@anirbandutta2266
@anirbandutta2266 3 ай бұрын
Well explained, you gave a good clarity of the concept, easy to remember + revise.
@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
@This.Object
@This.Object 19 күн бұрын
I can see a million things that can go wrong one of which is storing observer details in a list(in-memory) which is volatile if the pod dies which is a very likely scenario in a microservice world you'd loose all the subscribers details, you need to introduce a external storage space to hold that data and that itself takes a lot of time to discuss on how to implement that space as it is one to many it might introduce duplicate data issue if you use a mapping table as you duplicate the observable beside every observer and the list goes on and on😅 I had worked with Walmart before they ask you things that even they don't know how to solve so don't think this would satisfy them.
@gaurangmittal5563
@gaurangmittal5563 13 күн бұрын
@ConceptandCoding shreyans, initially you attached the gitlab link of the code examples also, could you please attach it again, or have you moved it to subscription model?
@muskan_bagrecha
@muskan_bagrecha 2 ай бұрын
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.
@umangmalhotra1222
@umangmalhotra1222 Жыл бұрын
While notifying observers, we should do the same in an asynchronous manner.
@abirpaul9027
@abirpaul9027 9 ай бұрын
the best teacher for lld
@ConceptandCoding
@ConceptandCoding 9 ай бұрын
Thanks 🙏
@AdityaSingh-pj7kw
@AdityaSingh-pj7kw 3 ай бұрын
Hey Shrayansh Can you please provide access to the notes and code used in the video? Keep up the great work!!
@dhirajrana397
@dhirajrana397 2 ай бұрын
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 ?
@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 3 ай бұрын
Kind of same. Where pub sub messages are preserved where as here fire and forgot no events are kept
@anshumansharma2251
@anshumansharma2251 3 ай бұрын
since a ecommerce website has too many products, do we have to create concrete observable classes for every product?
@SanketNagrale-f4t
@SanketNagrale-f4t 2 ай бұрын
Second wale case if we do setStock(100) then it adds to previous count of 10 hence we are not seeing it twice
@SyedaTabassum.
@SyedaTabassum. 2 ай бұрын
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?
@kanchankatkar5226
@kanchankatkar5226 Ай бұрын
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?
@weirdstrategist
@weirdstrategist 3 ай бұрын
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
@PankajGupta-gh9cm
@PankajGupta-gh9cm 22 күн бұрын
Hi Shreyansh, in case if user has notified for multiple products then in that case constructor injection will not work.
@harshpandey6799
@harshpandey6799 2 ай бұрын
doesn't using "instance of " takes less memory as if we create a has-a relation, all observer concrete class should have a reference of observable?
@Asingh42
@Asingh42 27 күн бұрын
Thanks this playlist is great! PS: In web are eventListeners and React States implementing the same thing??
@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 Жыл бұрын
Yes
@mahendrapatidar7416
@mahendrapatidar7416 Жыл бұрын
Bhai kya explain krte ho yr, maja aa gya. I love you.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you 🙂
@AMX0013
@AMX0013 Ай бұрын
@5:35 you mentioned ObserverInterface obj. When in a Interview, should I say ObserverImplementation instead? as Interfaces can't be instantiated to objects ? Or is it valid as it is just a Type definition?
@Lucifer-dd1zn
@Lucifer-dd1zn 5 ай бұрын
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 ?
@nishanthmekala1409
@nishanthmekala1409 3 ай бұрын
Shreyansh, Can we add multiple obervables to a single observer?
@dheeraj5531
@dheeraj5531 Жыл бұрын
Nicely explained everything ❤
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@PrateekSaini
@PrateekSaini 7 ай бұрын
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.
@rhimanshu6288
@rhimanshu6288 Жыл бұрын
Brother-- I am not sure about others but it took me 4 hours to understand the observer pattern-- but still not feeling confident. Could you please make a detailed one on explaining why we need this pattern??
@zishanshaikh9375
@zishanshaikh9375 9 ай бұрын
Do we need line number 19 to 21 in the Store class main method ?, as we are passing observable to observer, the observer can call add within the constructor of observer and pass this i.e. itself as a parameter, thereby registering itself with the observable
@sankarshana9170
@sankarshana9170 8 ай бұрын
NotifySubscribers method in the observable class needs the observers, since it loops through the array of observers and updates all of them
@umangmalhotra1222
@umangmalhotra1222 Жыл бұрын
I would like to see you using some Java 8 also . For example , forloop at 26:54 can be modified to something like this observersList.forEach(Observer::update); It would be a good show .
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Noted
@harshinredzone
@harshinredzone Жыл бұрын
No hard feelings but it is irrelevant to pattern. This is not Java tutorial otherwise someone would start suggesting using stream.
@umangmalhotra1222
@umangmalhotra1222 Жыл бұрын
@@harshinredzone mostly people with 2 yrs experience will come ok this channel, I have never seen a code where you will iterate a List using for loop.
@harshinredzone
@harshinredzone Жыл бұрын
@@umangmalhotra1222 people are supposed to learn few things on their own. If they don't have even this much of curiosity inside them, how much spoon feeding will be done? Anyway, like always, suggestions are opinionated. 🙂
@umangmalhotra1222
@umangmalhotra1222 Жыл бұрын
@@harshinredzone yes this is what I am sating, few things should be learnt on their own, if they see something they don't know, like streams API , they should look it up themselves So it should be cool for Shreyamsh to use Java 8 in his videos instead of naive looking for loops.
@harishaseri
@harishaseri 4 ай бұрын
What we we pass the concrete object in update method and in update we receive that only like : update(ObserverableConcreteClass obj) . in this case we i don't need to check the instance of right ?
@Coding-Just
@Coding-Just Ай бұрын
hey shrayansh can please suggest me which edition of Head first java and Head first design patten i have to buy for reading
@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
@krushnnabaviskar4131
@krushnnabaviskar4131 3 ай бұрын
Are you putting this code in any repo?BTW great efforts
@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 9 ай бұрын
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
@sambhav07
@sambhav07 5 ай бұрын
In case of Az, there are millions of users so for iphone notify me suppose 10 M people click on notify me so with oberserver design pattern there would be 10M Observer objects in the heap which will be only used if stock gets updated. Wouldn't that be waste on memory? Instead on stock update we can at runtime fetch the notification data from DB and notify the users
@abhishekjain5150
@abhishekjain5150 5 ай бұрын
I think we can use Kafka for notify this data , and we can store the data into the db . And every 5 minutes scheduler will run the query and distribute the data according to region or state or district. That's how netflix work
@anishranjan5714
@anishranjan5714 17 күн бұрын
If we update stock count to zero after a non-zero stock count. The stock count will not be updated back to zero.
@sameerchoudhary8590
@sameerchoudhary8590 7 ай бұрын
Very crisp and clear explanation.
@kushal7966
@kushal7966 Жыл бұрын
Thank You for the video . Can you suggest me which design pattern are helpful from Mobile (Android)App Development Point Of View
@Coding-Just
@Coding-Just Ай бұрын
It's second time not notifing because i thing we are adding in stockCount = stockCount + newStockAdded, 10 + 0 = 10; 10 + 100 + 110;
@SudhirKumar-oz4tk
@SudhirKumar-oz4tk Жыл бұрын
I have a query for a so long... do we need to create n number of classes similar to IPhone class .. because we will have lakhs of products in Amazon or Walmart and if we have to notify for every product... do we need to create individual classes for each and every product?
@tvb4026
@tvb4026 9 ай бұрын
Observable pattern ki kya jarurat ye to pub-sub se bhi ho sakta hai
@sameer9368
@sameer9368 Жыл бұрын
Awesome Explanation♥
@obsessiveDreamer
@obsessiveDreamer 2 жыл бұрын
agar hum constructor injection krte hai update method ke call keliye , toh observer keval ek hi observable se bind ho jayega , I mean the same observer will not get notify by multiple observable.
@parthrastogi5909
@parthrastogi5909 2 жыл бұрын
Bro why do we have multiple pbservable
@ShivamVerma02
@ShivamVerma02 2 жыл бұрын
We can have many to many relationship between observable and observor, for observor, we would need to one more method add(), which adds observable to list of obeservable ( similar to the way we have in observable class)
@deepanshu6576
@deepanshu6576 3 ай бұрын
what if one observer wants to get notfied for some obervable and not for othes then in that case we need to use if else in each observer update functioin then what is the point of keeeping a observable interface in observer ?? evern ater doing this we need to add if else ?
@atuldaschoudhury7571
@atuldaschoudhury7571 3 ай бұрын
Here in the video example, we have only 1 interface (StockObservable) and 1 class was implementing it. So u have the doubt that you want few of the concrete classes of StockObservable (interface) in the observer. Instead of using conditional branching u could divide the interface StockObservable further according to business requirements and pass the newly created interface from StockObservable to the Observer.
@paritoshdadhich2954
@paritoshdadhich2954 Жыл бұрын
Thanks for the wonderful explanation
@chaitanyaprasad6924
@chaitanyaprasad6924 8 ай бұрын
But in this case if a mobile observer wants to subscribe to Whether and Iphone how is it possible then ?
@vaibhavpopat99
@vaibhavpopat99 5 ай бұрын
great video :) qq - in the observer class, what of its observing >1 observables. In that case, is using 'instanceof' the only solution ?
@nitinkukreti2489
@nitinkukreti2489 Жыл бұрын
So In real world senario Relational DB is more sutable for observer pattern for sending notification to our users via web scokets as there are more add and delete (sub and unsub) operation ?
@UntamedRogueMavrick
@UntamedRogueMavrick 7 ай бұрын
At 14:40 if we are setting one observable object in the constructor, how will we get notified for mutliple observables (practically observer should be able to get notified for multiple items).
@gauravsharma4532
@gauravsharma4532 Жыл бұрын
Perfect , to the point explanation. Keep posting vedios👏
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@ROHITRAAZANAND567
@ROHITRAAZANAND567 7 ай бұрын
Would it be better to send all Emails using one Observer or Creating observer for each email? I was thinking ideally for each product, there would be 100s of subscribers and foir each we have to send email, And each of these email should be stored in Db. So we can read and create a Observer class at once.
@PrakashKumar-ts6xl
@PrakashKumar-ts6xl Жыл бұрын
Just one doubt will it be better to use set instead of list to store the observers because if one Observer is just clicking multiple times to notify me then we will have to add it multiple times for the same notification and he will again receive the notification multiple times.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Good point and yes we can use Set for it.
@ShubhamSharma-yg2tl
@ShubhamSharma-yg2tl 2 ай бұрын
Can you please upload all design pattern code in git. Will be big help to revise
@sristijaiswal1013
@sristijaiswal1013 8 ай бұрын
Isn't having both the setData() and notify() method in the same class violating the single responsibility principle?
@tastaslim
@tastaslim Жыл бұрын
What is the benefit of injecting the observable interface (StockObservable) in observer classes (EmailNotification, SMSNotification etc.) when you are not using it at all.
@balakrishna6240
@balakrishna6240 2 ай бұрын
Can you explain in English, in udemy also I found your videos in Hindi which I couldn't understand, isn't it possible to convert them to English language ?
@aeshwer
@aeshwer Ай бұрын
At 28.05, we can improve the business logic for setStockCount a sbelow if(stockCount == 0 && newStockAdded>0){ --- --- }
@rajdave7357
@rajdave7357 Жыл бұрын
Sir sach bolu Maja aagaya ❤❤❤❤
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@droid-aman
@droid-aman 4 ай бұрын
thnks for the vedio, sirJI it's a request git mai bhi upload kiya karo
@santoshbhatnagar2155
@santoshbhatnagar2155 9 ай бұрын
I have one question why are we storing the object of the stock Observable in the Observer class, what will be the other way to implement this, I saw the video but didn't get this part
@Shivam-wk6sq
@Shivam-wk6sq 2 ай бұрын
Where can we find these codes Shreyansh?
@shailesh5514
@shailesh5514 7 ай бұрын
Hey shrayansh , Considering a real world scenario where thousands of users are there is it right to say that when .add method will be called we will be saving in a DB instead of a observerList which is done here? I am curious to know how can a simple java list will host that much data related to observers And How this thing will Integrate with DB like storing list of observers etc?
@prakashshindalkar6959
@prakashshindalkar6959 2 жыл бұрын
very good explanation. Thank you
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
thank you
@zmxncbv95
@zmxncbv95 Жыл бұрын
Suppose, we have multiple classes which implement an Observable interface, e.g , ConcreteObservable1 has 2 properties, age and salary, and ConcreteObservable2 has 2 properties, city, and country, and the observers are interested in the state change of all these 4 properties, and we have the update() method in Observer interface which the concrete observers implements, then how are the observers going to get the data. As you told, we can have setState() in the Observable interface, what should be the return type of setState() in this case since the observers are interested in all 4 properties.
@ANSHULGUPTA880
@ANSHULGUPTA880 Жыл бұрын
observable class should contain different sets of notification, Set cityinterestedobservers; Set ageinterestedobservers; Whenever state is changing, based on what is changed , interested observers are notified.
@vipintripathi5362
@vipintripathi5362 Ай бұрын
We can pass the observable in update. And in update of observer, we can call the getData method of observable.
@patrisrikanth
@patrisrikanth 8 ай бұрын
Awesome Explanation ...
@ConceptandCoding
@ConceptandCoding 8 ай бұрын
thanks
@clutchh_god
@clutchh_god Жыл бұрын
For the update method in Observer why it will take param of type Object rather than of type Observable? It should ideally take Observable type param. If this true then we are not accomplishing anything with constructor injection way, because type casting will be required in both ways. Can you pls elaborate more on the benefits of constructor injection way instead of making it method param?
@vinothvellaichamy622
@vinothvellaichamy622 28 күн бұрын
hi , Please mention in description that this video is in Hindi..
@ConceptandCoding
@ConceptandCoding 28 күн бұрын
i already did in the membership level description
@ryan-bo2xi
@ryan-bo2xi Жыл бұрын
Let's say I have 3 million observers, should I iterate ?? Also, this code is storing the state in the app which can be a single point of failure, aka the observer list. Should I consider it stored in a cache rather than the application ??
@jagritbhupal5836
@jagritbhupal5836 2 ай бұрын
Amazing video, Thank you!
@Newbie789
@Newbie789 Жыл бұрын
great explanation, thank you so much for making this kind of video.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@samyakjain8079
@samyakjain8079 5 ай бұрын
33:01 minor correction stockCount = newStockAdded;
@vaibhavjaiswal7811
@vaibhavjaiswal7811 Жыл бұрын
Hi. I didn't get what would be the issue if we pass the same object to update method. Sorry, I am a noob. I mean, what issue would it create? Why would we need to check the instance of the class if we can directly call a specific method to do something on update. Thanks.
@lokeshrajput2458
@lokeshrajput2458 10 ай бұрын
when we make the object of observable, then it needs list of observer and to make the object of observer i need to give its observable, wont it create cycle?
@gmmkeshav
@gmmkeshav Жыл бұрын
IPhone is only a single product what about many products?
@Sushil2874
@Sushil2874 2 жыл бұрын
Very good explanation. BTW, which device are you using for writing in OneNote?
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
kzbin.info/www/bejne/pnmZcpuHrJ6qi80
@nishaaa_maurya
@nishaaa_maurya Жыл бұрын
Yha par, ek observer, multiple observable ko observe nhi kr skta. right ???
2. Strategy Design Pattern explanation | LLD System Design #1  | Design pattern explanation in Java
17:26
Being Competent With Coding Is More Fun
11:13
TheVimeagen
Рет қаралды 79 М.
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 2,5 МЛН
LIFEHACK😳 Rate our backpacks 1-10 😜🔥🎒
00:13
Diana Belitskay
Рет қаралды 3,9 МЛН
Observer Pattern - Design Patterns (ep 2)
49:47
Christopher Okhravi
Рет қаралды 565 М.
Mock Low Level System Design Interview with Qualcomm Sr. Engineer - Design Meeting Scheduler
37:23
Observer Design Pattern in Java
14:34
Telusko
Рет қаралды 172 М.
5. Factory Pattern Vs Abstract Factory Pattern Explanation, Low Level System Design interview
12:19