36. Visitor Design Pattern | Double Dispatch | Low Level Design

Поделиться
HTML-код
  • Опубликовано: 13 дек 2024

Комментарии • 39

  • @shankar7435
    @shankar7435 8 месяцев назад +5

    The best video on visitor pattern. Especially showing code snippets in the same structure that mimic its uml diagrams made this pattern understandable. Great technique. It worked wonders for this video.

  • @yogeshchanekar6263
    @yogeshchanekar6263 8 месяцев назад +1

    Best video I seen today which clear my doubt , Thank you buddy

  • @NishantTaletiya
    @NishantTaletiya Год назад +4

    wow kya samjate ho aap itna complex subject design pattern me samaj nahi pa raha tha ki exam me kya likhu kese karunga lekin aapke video dekhne ke baad sab aasan lag raha hai. me jab search karta kuch to likhta hu "this design pattern by concept and coding". Thank you so much.

  • @aishwaryatiwari7030
    @aishwaryatiwari7030 6 месяцев назад +3

    Another possible difference between Strategy and Visitor can be that Strategy uses composition to store different strategies where as Visitor is directly using double dispatch to call the required operation.

  • @khalidhashimeh
    @khalidhashimeh 7 месяцев назад +1

    You are a talented teacher..

  • @prakharporsa
    @prakharporsa 6 месяцев назад +2

    This is a great video! I have few questions though.
    In the example we have 3 rooms, what if we add new rooms? If we see the 2 problems it is trying to solve
    1. If we add a 4th room, we need to add a implementation of visit in all of the visitors which in turn is modifying the existing class(Visitor in this case)
    2. If we add more and more rooms, the class would get bigger and bigger
    So instead of adding more methods and making the class bigger, aren't we doing the same to visitor if we add more room?

  • @prashanthmeka354
    @prashanthmeka354 Год назад +2

    Explained with good example. Additional info about strategy pattern comparison gives even more context to the explanation. Appreciated 👍

  • @liquidmetal718
    @liquidmetal718 11 месяцев назад

    I think you missed about the advantage of visitor pattern - the visitor would not be aware of structure of hosting classes. The host class would unravel it's children , let visitor traverse through it and collect information. I think that's part where algorithm is separated from operations / actions possible on it.

  • @divyanarayanan1927
    @divyanarayanan1927 Месяц назад

    Thanks for this amazing explanation. I had a doubt, you told we add new operations without touching existing classes, but if we add new room like SuiteRoom, we will need to modify all visitors: RoomPricingVisitor, RoomMaintenanceVisitor to add new visit methods for SuiteRoom, so we will be change structure of existing classes here, right?

  • @LegitGamer2345
    @LegitGamer2345 Год назад +2

    Lets say that in the future a new room type is added, then we need to add its corresponding visit() function in all the already tested implementing visitor classes, is there a way to handle this without touching the tested classes ?

    • @ConceptandCoding
      @ConceptandCoding  Год назад +2

      Actually this is one of the disadvantage of Visitor pattern.

    • @ajayjangid1164
      @ajayjangid1164 9 месяцев назад

      Yes, as compare to “count-of-adding-new-room-type” with “count-of-adding-new-functions” is can be huge. so we can say that visitor pattern don’t completely removes re-testing and vertical growth of classes instead we can say it “minimizes” them.

  • @adityask22
    @adityask22 Год назад

    Hi,
    Great videos. Ive read multiple resources. However, your explanation on all patterns is very clear.
    On the next videos: Can we take some code from some repo and think of where all there is scope for improvement and which Design Pattern can help us solving it. This helps in identifying the actual design pattern needed and very much needed in our real world.

    • @ConceptandCoding
      @ConceptandCoding  Год назад

      Awesome input, thanks, will add it to my bucket list

  • @charutandon5317
    @charutandon5317 7 месяцев назад

    Hi, what do you use to create these UML diagrams? @ConceptandCoding ?

    • @ConceptandCoding
      @ConceptandCoding  7 месяцев назад

      Wacom pad and any draw application like OneNote

  • @sameer9368
    @sameer9368 Год назад +1

    Great tutorial so far I have gone through

  • @baburaomulaparthi4531
    @baburaomulaparthi4531 8 месяцев назад

    Nice vedio. graet explanantion.
    can we declare Roomvisitor as below.
    interface RoomVisitor{
    void visit(RoomElement element);
    }
    if new roomtype added in future.

  • @WasteMaterial-vr3qe
    @WasteMaterial-vr3qe 8 месяцев назад

    When you approach a problem in interview or in your work. How do you think like this design pattern can work?
    I know in every pattern video you have told when it can be used but still it's not a piece of cake to figure out the design pattern
    Eg: In Apply Coupon Video of yours, I implemented without Decorator but you used Decorator. How come you or anyone think in that direction? If you can share insights, it might help others as well.

    • @shankar7435
      @shankar7435 8 месяцев назад

      That's the game of problem solving ability companies look for. It comes with practice and many refer it as experience.😊😊😊

  • @crazeeealgorithms3236
    @crazeeealgorithms3236 10 месяцев назад

    Lets say that in the future a new room type is added, then we need to add its corresponding visit() function in all the visitors so here we are again modifying the existing code to accommodate the new room, will this not violate open/closed principle?

    • @yogeshchanekar6263
      @yogeshchanekar6263 8 месяцев назад

      When using the Visitor pattern, you define a separate visitor interface and implement different visitor classes to perform operations on elements of an object structure. In Java, this typically involves implementing the accept method in each element class, which takes a visitor as an argument.
      A violation of LSP could occur if adding new element subclasses requires modifying the visitor interface or any of its implementing classes. If this modification causes unexpected behavior or forces changes in existing visitor implementations, it could potentially break the principle.

  • @anketpatel2312
    @anketpatel2312 Год назад +1

    I can understand the things but sometimes I feel like better to do simple code without this kind of design pattern.
    Simple code is always easy to understand and update.

    • @ConceptandCoding
      @ConceptandCoding  Год назад

      Definitely they are, but if you see, Java lib which we are using are full of usage of design patterns.
      So these principles and pattern do have an impact on scalability.

    • @rabindradocument8934
      @rabindradocument8934 Год назад +1

      ​@ConceptandCoding can you please show where this design pattern used in java lib

  • @yuvhrajverma6158
    @yuvhrajverma6158 Год назад

    sir in command pattern whats the role of invoker apart from applying undo feature like if we don't want undo feature then client already has reference to command and the receiver so client can directly call commands execute method and still there is no tight coupling between client and receiver and in uml why client doesn't have a HAS-A relation with invoker , plz reply sir

    • @ConceptandCoding
      @ConceptandCoding  Год назад

      ack of the question

    • @LegitGamer2345
      @LegitGamer2345 Год назад

      think about it like this: u can perform operations on a TV with a remote, but u can also do things like changing the channel and increasing/decreasing the volume directly by interacting with the TV also, then what is the use of remote ?

  • @shubhamaptekar7748
    @shubhamaptekar7748 8 месяцев назад

    I am confuse that stratergy and bridge look similar because both focus on seprating a feature . Please help

    • @ConceptandCoding
      @ConceptandCoding  8 месяцев назад +1

      Shubham, you will find many patterns similar and doing same thing,
      only thing differs is intention.
      Strategy is Behavioral patterns which more focus on how to divide the responsibilities between objects (or in simple term how different objects should communicate whith each other)
      while bridge patterns is a structural pattern, which focus on how to organise objects to form a large structure.
      Ultimately both solution looks same but they tried to solve diff things, and same thing you find with many other patterns which look similar

    • @shubhamaptekar7748
      @shubhamaptekar7748 8 месяцев назад

      @@ConceptandCoding thank you for taking time and replying sir

  • @NamanJain-dj7te
    @NamanJain-dj7te 7 месяцев назад

    can you share its pdf?

  • @sargamgoyal4161
    @sargamgoyal4161 Год назад

    Hi @ConceptandCoding ,, Thank you so much for such great content. Can you please make LLD videos on Swiggy / Zomato && Make my Trip, if possible. It will be very helpful.

  • @dhaanaanjaay
    @dhaanaanjaay 5 месяцев назад

    this pattern is not making any sense. First we say to avoid retest of code we extract operation logic to new class. But what if in future We add a new room and we have multiple visitor, we would need to change all visitor classes

  • @AnkitSharma-bp5rc
    @AnkitSharma-bp5rc Год назад

    Great Video, but why did you change your language from Hindi to English. Your videos in Hindi were much more involving. It's very easy to understand stuff in our mother tongue.