4. Decorator Design Pattern Explanation with Java Coding, LLD System Design, System design interview

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

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

  • @ashutoshkumar4565
    @ashutoshkumar4565 Год назад +56

    I always wondered why "is-a" and "has-a" relationship between objects is even worth mentioning, but now I know just how important they are. It's amazing how a small detail like this can completely change the way we approach programming.

  • @sagar1691
    @sagar1691 11 месяцев назад +6

    I worked in both product and service industry of small, medium and large size company, i can see the clear understanding and explanation by the narrator on each of the topic and make an analogy to live code in my work. Very well explained in details, that too free of charge ,i recommend these videos to all the freshers or laterals who are working in java for upskilling.

  • @d2j1-a
    @d2j1-a 11 месяцев назад +3

    Just can not believe that this piece of gem is free on youtube !!
    Really appreciate your efforts. :)

  • @patrisrikanth12
    @patrisrikanth12 11 месяцев назад +5

    Unbelievable that we are getting this video for free of cost.... Awesome explanation.

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

      bhai ne kuch videos paid kr di 😁

  • @wul_frik
    @wul_frik Год назад +17

    Amazing concept, learning LLD is really an eye-opener. Thanks for this amazing video and explanation.

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

      Thank you, pls do share it with your connections 😊

  • @ShabnamKhan-cj4zc
    @ShabnamKhan-cj4zc 19 дней назад +1

    Thank you so much for explaining in very detailed manner with code . This helps to understand the topic clearly instead of having doubts..

  • @PujaSingh-qg5ln
    @PujaSingh-qg5ln 4 месяца назад +1

    Thanks Shrayansh for making these lld videos easier to understand. Apprepriate all your hard work.

  • @TECH_PANDA_23
    @TECH_PANDA_23 9 месяцев назад +1

    very good explanation is the best, simplicity is the base here and visual representation is toppings

  • @cybergurucool2632
    @cybergurucool2632 Год назад +3

    Superb explanation. To recollect decorator pattern, I will remember the pizza example. Thanks a lot of this super useful video.

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

    🤯🤯🤯🤯🤯
    Swaad hi agya 😋😋😋😛.
    Thanks Shreyansh for this Amazing vedio series. Great content. And Beautifully explained.

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

    Nice point : both isA and hasA property is needed! Awesome Explanation!

  • @yashbehara7525
    @yashbehara7525 15 дней назад +1

    Well structured and explained! Thanks a lot!

  • @ayushigupta685
    @ayushigupta685 11 месяцев назад +1

    I really appreciate your efforts thankyou so much😇😇😇😇👏👏👏👏👏

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

    The way you explain with examples it makes the concept very clear..Keep it up and thank you very much :)

  • @VinayakKhairnar-bb7oc
    @VinayakKhairnar-bb7oc 7 месяцев назад

    'Has a' and 'is a' make concept much simpler to understand. Good point you make to explain.

  • @sravanakirtana2787
    @sravanakirtana2787 9 месяцев назад +1

    Awesome explanation Sir. Thank you very much

  • @yashgupta6726
    @yashgupta6726 2 года назад +7

    Wish had explored your channel a bit earlier, awesome content on Low-level design(one-stop solution), Just feedback if you can arrange the videos of the playlist in what order to watch it will be really great for people.

    • @ConceptandCoding
      @ConceptandCoding  2 года назад

      Thank you Yash, not sure if youtube does not show playlist title and description, i have mentioned in both the place that Start from bottom and move Upward, let me check

  • @praveenkrdas72
    @praveenkrdas72 9 месяцев назад +1

    Great job Shrayansh .

  • @adityarout1276
    @adityarout1276 2 года назад +2

    I can totally relate Decorator Design Pattern now, yestarday only i ate the 'PIZZA' now i'm learning and watching it. 😃✌

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

    Very good explanation with code...u did awesome job. really thanks a lot.

  • @prashantgupta6160
    @prashantgupta6160 2 года назад

    thoda nhi, bahut useful h bhai, please continue LLD series, you are one of best educators on RUclips

  • @manashimazumder7185
    @manashimazumder7185 Год назад +3

    Great content. First time i am feeling confident about LLD. Please share your knowledge more with us :)

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

      Thanks there is a complete in depth playlist Manashi:)

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

      @@ConceptandCoding Yes am checking. Thanks again for the content.

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

    Bhai ek number i never imagined that i can also understand LLD. Every said that LLD and HLD is hard but now i feel i can also learn these concepts. Thanks bro and can you suggest the book that help me to learn HLD and LLD. It will be very helpful.❤❤

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

    Amazing video Shrayansh!!

  • @harshinredzone
    @harshinredzone 2 года назад +2

    Thanks for sorting it in "reverse" order. Glad that you considered the feedback. 😀

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

    Thank you sir..today I start calling u sir..Thank you for ur efforts 🙏

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

      Thanks a lot buddy but call me Shrayansh, we both are students,let's keep learning and sharing

  • @saifurrahmanbhuiyan925
    @saifurrahmanbhuiyan925 Год назад +5

    Such awesome content, then its free. i cant explain how satisfied i am satisfied with your content. Thanks a lot bro. i have one request bro, whether you provide content free or paid, it does matter. just keep up. i have seen lots of videos and read books regarding design pattern. nobody explained like you. one thing makes your content unique, you deeply explain OOP concept behind design pattern.

  • @realthings7931
    @realthings7931 2 года назад +1

    Great Explanation. Thanks for the video🙏

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

    Thanks Shreyansh. Video is very helpful in understanding. I have implemented the same in python. Awesome initiative

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

    Awesome, simply awesome

  • @himanshusingla2198
    @himanshusingla2198 Месяц назад +1

    Really helpful ❤

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

    this video is a GEM to the whole community, that too by a GEM..... hats off 2 u sir.. all this premium content for free , not possible on this whole planet itself,....
    wish the java playlist would also become public / free someday , so that it can reach to every deserving candidate who cant afford the subscription at that point of time... s teachers like you are rare to find, your knowledge is uncomparable...

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

    I really understood this design pattern. thank you sir for wonderful explaination

  • @shawkiahmed3586
    @shawkiahmed3586 5 месяцев назад +1

    Thanks for the explanation with the examples.

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

    Thank you sir for another awesome video.

  • @imranmohamed5467
    @imranmohamed5467 Год назад +3

    Nice video. You can add the main class with example of creation of these objects and using them that would help understand the concept better.

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

      public class PizzaShop {
      public static void main(String[] args) {
      BasePizza base = new VegDelight();
      System.out.println(base.cost());
      BasePizza customPizza = new ExtraCheese(new Mushroom(new Farmhouse()));
      System.out.println(customPizza.cost());
      }
      }

  • @sreshthisingh8949
    @sreshthisingh8949 2 месяца назад +1

    very useful very nice video

  • @amitgupta-or5nm
    @amitgupta-or5nm 2 года назад +1

    Great expansion 😃 ....

  • @guruvedharamanan3153
    @guruvedharamanan3153 2 месяца назад +2

    If i need 2* cheese 3* mushroom , how it can be achieved , instead of mutiple classes we can have db to store the details ?

  • @akshaymahajan9626
    @akshaymahajan9626 11 месяцев назад +1

    Great work !

  • @Rabbitv-r8s
    @Rabbitv-r8s Год назад +2

    Awesome explanation

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

      Thanks

    • @aakashgoswami2356
      @aakashgoswami2356 2 месяца назад

      LLD k members only videos mai jo questions hai like design parking lot etc unke code bhi included?

  • @homestaysandcafes
    @homestaysandcafes 2 года назад +1

    Very Well explained sir!

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

    Thanks for this playlist sir. Means a lot to us

  • @vikasumTrader
    @vikasumTrader 2 месяца назад +1

    mindblowing!!!!

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

    Maza Aagya
    respect++

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

    Thanks!

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

      thanks a lot buddy for super thanks 🙏

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

      @@ConceptandCodinghello sir , i want to become member so I can access all your videos of this lld series. Please tell me the process

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

      at channel home page you will find the join button, there you can join “Unlock LLD, HLD..” one

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

      @@ConceptandCoding thanks joined

  • @durgeshrai04
    @durgeshrai04 2 года назад

    Awesome Explantion

  • @pranav8937
    @pranav8937 6 месяцев назад +1

    J is silent in jalapeno😅. Rest video was awesome!!

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

    Great Video , thanks a lot

  • @princesharma-wi3kn
    @princesharma-wi3kn 7 месяцев назад

    Thank you so much for the detailed explanation :)

  • @hardik_aswal
    @hardik_aswal 5 месяцев назад +1

    How do we handle the case where 2 features are not compatible with each other? For eg. Say in car configurator, user selected both chrome grill and black grill, one of them has to be removed. First the user selects chrome grill so price increases by 100, then user selects black grill so first we have to reduce price by 100 which is for chrome grill, then we add 80 for the black grill.

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

    Great explanation. But I need to revisit the example once again.

  • @ankitkumaryadav562
    @ankitkumaryadav562 5 месяцев назад +1

    Very helpfull video

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

    perfect brother i understood

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

    To easy understanding of layer, we can follow below object instantiations
    // Here Customer first adds Farmhouse pizza
    // then adds extra cheese on top of if
    // then add extra mushroom
    // we can pass same BasePizza object to new topping
    BasePizza pizza = new Farmhouse();
    pizza = new ExtraCheese(pizza);
    pizza = new ExtraMushroom(pizza);

  • @shatrudhankumar7824
    @shatrudhankumar7824 10 месяцев назад +1

    Awesome😍

  • @shantahiremath7313
    @shantahiremath7313 3 месяца назад +1

    Thank you Sir

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

    You are awesomeee🔥🔥❤

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

    Could you please explain for the Pizza example, why not use builder pattern instead?

  • @parag-kumar
    @parag-kumar Год назад +1

    Great explanation! :)

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

    what was the use of declaring the has a in toppings[ extraCheese] , are we using it some where?

  • @aayushkumar6727
    @aayushkumar6727 4 месяца назад

    @ConceptandCoding Why do we we use abstract class here an not interface ?

  • @utkarshjaiswal7224
    @utkarshjaiswal7224 9 месяцев назад +1

    Can we use interface instead of abstract class..I both in this case both will work fine

  • @SHASHIKUMAR-pp4hg
    @SHASHIKUMAR-pp4hg 3 месяца назад

    hey Shrayansh , i have one query in base abstract class why cannot we set quantity of toppings and calculate cost ?

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

    Let's say we have created a pizza object with 3 toppings, how do we backtrack to know which toppings and which base pizza was selected while storing in the db ?

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

    thanks for detailed video -- why BasePizza and ToppingDecorator in not defined as Interface ?

  • @vaibhavseth90
    @vaibhavseth90 18 дней назад

    I din understand isA and hasA property can you point out which video to watch.

  • @pulakammalathy6968
    @pulakammalathy6968 6 месяцев назад

    why is base pizza and topping decorator abstarct classes ? can they be interfaces? Iam not able to justify this point properly

  • @himanshuchhikara4918
    @himanshuchhikara4918 10 месяцев назад +1

    why you used abstract class , can we use interfaces also ?

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

    faad diya bhai

  • @bhavyemalhotra1584
    @bhavyemalhotra1584 6 месяцев назад

    will the code break if we remove has a relationship(don't extend) in toppingdecorator? I think it will not break atleast in your example

  • @Narendra-Pratap-singh
    @Narendra-Pratap-singh 7 месяцев назад +1

    thanks for the video

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

    Super clear, I had a doubt: So according to this example "ExtraCheese" is a BasePizza due to indirect inheritance.
    So in Vehicle example, the decorator would extend the BaseVehicle. Power Steering would inherit from decorator and in-directly have a "is-a" relationship with BaseVehicle, right
    So in a way we are saying power-steering is a BaseVehicle so is it right? As power steering is not a Vehicle rather its a feature

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

      Correct, if you want this pattern and design car with this way. Then you are right

  • @hiren6691
    @hiren6691 2 года назад +1

    keep going :)

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

    Very thanks

  • @NitinKumar-gv4hs
    @NitinKumar-gv4hs 2 года назад +1

    Can you explain what does has-a keyword mean , here ?
    @13:34

    • @ConceptandCoding
      @ConceptandCoding  2 года назад

      Ack

    • @NitinKumar-gv4hs
      @NitinKumar-gv4hs Год назад

      @@ConceptandCoding I didn't understood, had had one doubt could we do this by creating interfaces as well ?

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

    Thank you so much for the amazing contents

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

    Hi,
    Suppose we have an abstract pizza class and an abstract toppings class which are inherited by concrete classes . Now, every pizza class has a list of toppings . So, when we calculate the cost, we just iterate over that list and compute the total cost. I have a big doubt that if only has-a relationship is solving this problem. Why do we need such a complex structure of has-a and is-a relationship existing at the same time and what extra advantage does decorator pattern bring into picture ?Looking forward to your reply to this question.

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

      okay, could you please tell me, how you would solve the scenario where you have 1000s of combination like
      BasePizze,
      BasePizze + cheese ,
      BasePizza + mushroom,
      Veggie + cheese and go on......
      The biggest advantage decorator pattern adds up is control on number of classes if there are so so many combinations possible.

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

      @@ConceptandCoding Thanks for your reply.
      Lets suppose Base pizza is extended by two Pizza class Veg and Non Veg Pizza. I have another ExtraAddOn class which is inherited by say cheese, mushroom, paneer and so on ...
      Now, I have a " vector extraList; " in Veg and Non Veg Pizza class.
      So, whatever combinations of ExtraAddOn you need, you can add to that list and calculate cost.
      Only thing is that you cannot mix the base Pizza options, but i don't think that's the requirement here. Am i thinking it wrong ?

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

    Please explain when to use decorator pattern and builder design pattern and differemces. Both seems similar.

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

    In my approach, I used an interface for defining a behavior and then created multiple concrete classes implementing this interface, each representing a different behavior. This seems somewhat similar to the Decorator Pattern, where each decorator wraps an object and adds its behavior.
    However, I'm struggling to see a significant advantage of the Decorator Pattern over my approach in terms of scalability, flexibility, and maintainability, especially when considering the addition of new behaviors. In both cases, adding a new behavior seems to require just adding a new class without modifying existing ones. Could you help clarify the specific advantages of using the Decorator Pattern over this approach?

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

      You have created A,B C different concrete classes. If you want to create new concrete classes with properties of lets say B , with decorator pattern you will have B1 , B2 etc. But without decorator pattern you might have to write more code to not only include the property of B but also its own new property.
      I hope this helps.

  • @akhilsharma1778
    @akhilsharma1778 2 года назад +2

    Why are we using ToppingDecorator? If we are anyways inheriting Extracheese then can't we inherit it directly from BasePizza as we aren't doing anything in ToppingDecorator class?

    • @niwanshumaheshwari4534
      @niwanshumaheshwari4534 2 года назад

      So here inheritance is only used for type matching and composition is used to get the behaviour.

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

      It will give us flexibility in future

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

    Others : Learning Decorator Pattern from this Video
    Meanwhile me -> Learning and Ordering a Margarita Pizza after watching 😂

  • @krishnaveerakishoremuppana9189
    @krishnaveerakishoremuppana9189 2 месяца назад

    Thanks for the explaination. Really loving LLD. Used interface instead of abstract class for BasePizza and Toppings. Do you think there will be an issue in this approach?

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

    Can we have array if Toppings in Pizza Class and while calc cost in Pizza class add topping's cost also. 🤔

  • @your_name96
    @your_name96 2 года назад

    really thank you sir for your huge efforts, but sir, if we keep a final ingredients price Map in Base Pizza itself, and keep Topping Map containing topping and its frequency, this can be solved much simply for calculating the price, but then again that solution is not scalable ig when toppings list and price need to be updated, thanks again.

  • @Shefalisingh-m1m
    @Shefalisingh-m1m Год назад

    Can you show the working demo as well. Need to understand how is main working. Based on input(order is magaretia plus extra cheese etc..)?

  • @AbhilashPareek
    @AbhilashPareek 2 года назад +1

    ExtraCheese and mushroom can also extend basePizza right?
    Why do we have another abstract class in between?

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

      Exactly. I have the same question in my mind.

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

      yeah it can directly extend BasePizza but abstract decorator can help in avoiding code duplication. In video it was not showed but instead of creating BasePizza instance in each of the decorator subclasses, you can use abstract Decorator class to handle that functionality and it would make sure that all decorator subclasses will follow same structure

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

    Do you have any github repo for notes or doc link ?

  • @AjeetTumuluru
    @AjeetTumuluru 3 месяца назад

    Coming from a C++ background. Why did you use abstract class over interface here?

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

    How is a topping "is-A" basePizza? Does that make sense?

  • @harshitkumar4129
    @harshitkumar4129 3 дня назад

    can we use interface instead of abstract class

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

    Such a great content!:)

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

    can we not use interfaces instead of abstract classes ?

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

    For the pizza making or adding accessories to car, builder design pattern seems more useful. What’s your say?

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

      could you please try to implement it and see what challenge you are facing.

  • @prashantkumar-hx1dv
    @prashantkumar-hx1dv Год назад

    Sir please help. I have taken membership and it is showing member as well but not able to see the Parking lot. or other imp videos uploaded.

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

      Hi Prashant, to unlock LLD questions, you need "Unlock LLD, HLD, Java" membership level.
      I think currently you have taken "Appreciation" level one.

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

    from where we can get the notes of these lectures?

  • @charan775
    @charan775 2 месяца назад

    why cant we do iteration over toppings and get cost? why do we need this?

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

    Firstly loving your videos! So thanks for that
    Q. Is this really good to do something like new ExtraCheeze( new ExtraPanner(new FarmHousePizza())))...
    B'coz not Basepizza object in ExtraCheese already contains a topping of ExtraPanner....
    While if we were not to use Decorator design pattern... We would have had all the toppings on same level... (May be with a boolean flag)
    It might matter if we don't want cheese on top of panner but panner and cheese mixed very well... (Sty could not think of a better example)

  • @DevArora-v6i
    @DevArora-v6i Год назад +1

    Can you explain why you used decorator abstract class in between rather than extending base pizza in ExtraCheese and ExtraMushroom classes?

  • @ayushsamyal9070
    @ayushsamyal9070 2 года назад +1

    Hi, Thanks for the great explanation. One small request could you please share the notes and the code that you are using for the explaination in each video. It would be beneficial.