Design a Vending Machine | LLD Interview Question | State Design Patterns | OOPS | Java

Поділитися
Вставка
  • Опубліковано 6 січ 2025

КОМЕНТАРІ • 72

  • @vatsalmaheshwari692
    @vatsalmaheshwari692 2 роки тому +15

    I believe that this does not fulfill Interface Segregation principle of SOLID principles. There is no need of insertCoin and presButton in some cases. We should make different interfaces if any state does not want to implement a function. Tell me if I am wrong. I would love to get corrected.

  • @rohitshaw6862
    @rohitshaw6862 2 роки тому +1

    A much needed content. Very few people are there who create videos on this topic. Thank you for your initiative 😁.

  • @fares.abuali
    @fares.abuali 2 роки тому +1

    Thank you so much, Mr. Riddhi.
    Consie & Informative

  • @aishwaryapani4662
    @aishwaryapani4662 2 роки тому

    Very helpful video, at a time when there is a dearth of LLD resources. Thank you for making these ❣

  • @sarfrazz34
    @sarfrazz34 2 роки тому +5

    Riddhi, could you please share the git repo link for the same?

    • @chetanpareek4428
      @chetanpareek4428 6 місяців тому

      @Riddhi could you please share the github link of this code ?

  • @debmalyapan53
    @debmalyapan53 2 роки тому +1

    this was highly required. thanks da.

  • @snehomoymaitra9317
    @snehomoymaitra9317 2 роки тому

    Amazing content as many of the companies are asking LLD questions in their SDE-1 (e.g - freshers) interviews.

    • @rite2riddhi
      @rite2riddhi  2 роки тому +2

      Thank you ❤️

    • @vinamrasangal8436
      @vinamrasangal8436 6 місяців тому

      how can a person write such a big LLD code in just 1 hr ???

  • @sudipasarkar7981
    @sudipasarkar7981 2 роки тому

    Amazingly explained much needed one😃😇

  • @Kapil_Sharma_Engineer
    @Kapil_Sharma_Engineer 2 роки тому +1

    Small doubt is do we really need a State interface on which Vending machine is dependent. I feels like we can have a enum of states or a current state variable based upon that we can give the functionality output

    • @rite2riddhi
      @rite2riddhi  2 роки тому +1

      Won't that result in a lot of if else handling? How would you achieve runtime polymorphism?

    • @Kapil_Sharma_Engineer
      @Kapil_Sharma_Engineer 2 роки тому

      @@rite2riddhi yes there will be more if-else handling. And regarding polymorphism maybe I will use a strategy pattern but one this is I will give try to use the Abstract class with default function definition so that we don't need to define a function with the same functionality in multiple classes

    • @rite2riddhi
      @rite2riddhi  2 роки тому +1

      @@Kapil_Sharma_Engineer using multiple if else might not be good for code readability. But yes , again design is an open ended discussion. 😅

    • @Kapil_Sharma_Engineer
      @Kapil_Sharma_Engineer 2 роки тому

      @UCKyTTBdDH3I%F0%9F%98%87635HQMrPvz_A Completely agrees every person has their own view to look at the problem and give the solution accordingly 🙂

  • @chiragkarnwal6740
    @chiragkarnwal6740 2 роки тому +1

    Thanks sir very helpful video 😊❤️

  • @abhishekrai5212
    @abhishekrai5212 2 роки тому

    I really liked the design as well as the explanation. Please create more such LLD design content👍

  • @rohitshaw6862
    @rohitshaw6862 2 роки тому +4

    Also can you please wrap the whole content in single playlist, so it will be easier for me to track all the videos. Thank You.

    • @rite2riddhi
      @rite2riddhi  2 роки тому +2

      Sure

    • @chetanpareek4428
      @chetanpareek4428 6 місяців тому

      ​@@rite2riddhi can you please provide the gjithub link of this code ?

  • @harshraj22_
    @harshraj22_ 2 роки тому

    It's kind of strange that states need vending machine to initiate, and vending machine meeds states. Looks like a kind of circular dependency, and becomes more confusing when you think composition in terms of " class has a" property.
    Also, taking out inventory instance out of vending machine class, and performing operations on it doesn't sound quite good to me. Wouldn't it be more better if vending machine rather exposes some methods to operate on inventory, rather than giving off its internal objects to outsiders ?

    • @rite2riddhi
      @rite2riddhi  2 роки тому

      For 2 , yes have added addProductToInventory() in the Vending Machine itself. User will only interact with VM. I focussed on the main problem , hence skipped few things.
      For 1 , it won't be a cyclic dependency. Again , as I said no design is perfect , and it is not possible to come up with a flawless design in a 1hr interview.

  • @soumyarv4018
    @soumyarv4018 Місяць тому

    Can you please explain any idea on how to implement online payment in place of adding a coin .

  • @JigyasaGupta-nx9pk
    @JigyasaGupta-nx9pk 2 роки тому

    do u have a git hub link

  • @dopamine003
    @dopamine003 Рік тому

    Great explanation

  • @Anonymous____________A721
    @Anonymous____________A721 4 місяці тому +1

    Thanks GOAT

  • @obsessiveDreamer
    @obsessiveDreamer 2 роки тому

    Are you passing the object of the vending machine into all three states' constructors as a reference or a copy of the object? I mean all three states is working on the same instance of vending machine?

  • @Maneeshce2007
    @Maneeshce2007 Рік тому

    Where is the github url to find the code ??

  • @pratosh
    @pratosh Рік тому

    is there any github repo for this design?

  • @namantyagi6294
    @namantyagi6294 2 роки тому

    In an actual lld interview, do we need to write the whole methods and class or just a skeletal design with the classes and methods just declared and not completely implemented?

    • @rite2riddhi
      @rite2riddhi  2 роки тому

      Depends. In an lld interview , important functions you have to write. For machine coding , you have to write everything.

  • @divyajyotibasu3001
    @divyajyotibasu3001 Рік тому

    Hi, Thanks for the helpful tutorial. If possible kindly share the codebase in a repository. Regards!

  • @zahidkhan-ln3jv
    @zahidkhan-ln3jv 2 роки тому

    Great explanation! Can we use the same design pattern to design a shopping cart?

  • @tanveer.shaikh
    @tanveer.shaikh 2 роки тому

    instead of throwing illegal state can we sent some warning and be on same state

  • @akankshagaur845
    @akankshagaur845 Рік тому

    can we get the source code link as well @Riddhi Dutta

  • @rishav144
    @rishav144 2 роки тому

    need more LLD videos like this ....please

  • @hell-o8470
    @hell-o8470 2 роки тому

    where can i get the code?

  • @chodingninjas7415
    @chodingninjas7415 2 роки тому

    Great stuff

  • @raginibhadani7257
    @raginibhadani7257 2 роки тому

    Is this code available somewhere?

  • @satyajeetkumarjha1482
    @satyajeetkumarjha1482 2 роки тому

    Can you post the link to GitHub repo?

  • @iamdips00356
    @iamdips00356 2 роки тому

    Amazing video

  • @nikhilk4735
    @nikhilk4735 2 роки тому

    Great explanation. Can you please share link to this code repo

  • @vishalmishra1937
    @vishalmishra1937 Рік тому

    plz share the code link

  • @debmalyapan53
    @debmalyapan53 2 роки тому +1

    also plz make a video on elevator, distributed cache, splitwise. 😁

    • @rite2riddhi
      @rite2riddhi  2 роки тому

      Next singleton then elevator

    • @Lucifer-xt7un
      @Lucifer-xt7un 2 роки тому

      @@rite2riddhi bro please maintain consistency in this series and increase frequency of making videos

  • @ManeyyNeg
    @ManeyyNeg 7 місяців тому

    pls share github link

  • @sayankarmakar13
    @sayankarmakar13 Рік тому

    It will be very helpful when you share the github link

  • @kumarabhishek6777
    @kumarabhishek6777 Рік тому

    you explain nicly but i am getting error in this ,,,, might be missing something so if possible provide the source code of the pattern

  • @vinamrasangal8436
    @vinamrasangal8436 6 місяців тому

    give code plz

  • @meme_engineering4521
    @meme_engineering4521 2 роки тому

    bhai i wanted to ask, how important is LLD for freshers? and especially for campus placements

  • @thesoftwareengineer17
    @thesoftwareengineer17 2 роки тому

    bro plz add github links for all these questions too

  • @digitaljunk
    @digitaljunk Рік тому

    To reduce echoing and delay in the recording point the microphone opening towards the sound source (your mouth). Please don't record the room space.

    • @rite2riddhi
      @rite2riddhi  Рік тому +1

      Hey this is an old recording. Sound is sorted now.

  • @lokey8084
    @lokey8084 Рік тому

    This feels like it breaks Liskov's substitution principle

  • @Mukeshkrk108
    @Mukeshkrk108 2 роки тому

    sir MIke and Voice is not clear and Sir on more thing that is You talking very fast

  • @rakeshpramanik
    @rakeshpramanik 2 роки тому

    Wow

  • @cj-nr5ni
    @cj-nr5ni Рік тому

    Dude

  • @ratimohan5765
    @ratimohan5765 Рік тому

    You explain very fast, need extra effort to understand. Didn't like this tutorial.

    • @rite2riddhi
      @rite2riddhi  Рік тому

      Oh so sorry to hear that.. I would try to be slow from next time. You can watch it at 0.75x for now.

    • @no_name45689
      @no_name45689 Рік тому

      Exactly.

  • @RishabAgarwala
    @RishabAgarwala 10 місяців тому

    I guess you could have improved the design more by not create Objects of each state

  • @aditigupta6870
    @aditigupta6870 9 місяців тому

    Why are you unnecessarily violating interface segregation just to explain a state design pattern?