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

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

Пікірлер: 307

  • @ashutoshkumar4565
    @ashutoshkumar4565 Жыл бұрын

    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.

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Glad to know that

  • @user-pq6xi2bb9o
    @user-pq6xi2bb9o5 ай бұрын

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

  • @sagar1691
    @sagar16915 ай бұрын

    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.

  • @wul_frik
    @wul_frik Жыл бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you, pls do share it with your connections 😊

  • @tarunkundhiya5196
    @tarunkundhiya5196 Жыл бұрын

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

  • @TECH_PANDA_23
    @TECH_PANDA_233 ай бұрын

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

  • @adhyanneekhra4853
    @adhyanneekhra4853Ай бұрын

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

  • @VinayakKhairnar-bb7oc
    @VinayakKhairnar-bb7ocАй бұрын

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

  • @sravanakirtana2787
    @sravanakirtana27873 ай бұрын

    Awesome explanation Sir. Thank you very much

  • @omkarsharan3967
    @omkarsharan3967 Жыл бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Glad it helped!

  • @patrisrikanth
    @patrisrikanth5 ай бұрын

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

  • @kartikag01

    @kartikag01

    3 ай бұрын

    bhai ne kuch videos paid kr di 😁

  • @cybergurucool2632
    @cybergurucool2632 Жыл бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Welcome

  • @programming6556
    @programming65563 ай бұрын

    Great job Shrayansh .

  • @yashgupta6726
    @yashgupta6726 Жыл бұрын

    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

    Жыл бұрын

    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

  • @ayushigupta685
    @ayushigupta6855 ай бұрын

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

  • @princesharma-wi3kn
    @princesharma-wi3knАй бұрын

    Thank you so much for the detailed explanation :)

  • @hbolchatwar5308
    @hbolchatwar5308 Жыл бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you

  • @DivineVision201
    @DivineVision201 Жыл бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Glad to hear that

  • @homestaysandcafes
    @homestaysandcafes Жыл бұрын

    Very Well explained sir!

  • @manashimazumder7185
    @manashimazumder7185 Жыл бұрын

    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

    Жыл бұрын

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

  • @realthings7931
    @realthings7931 Жыл бұрын

    Great Explanation. Thanks for the video🙏

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    thank you

  • @akshaymahajan9626
    @akshaymahajan96265 ай бұрын

    Great work !

  • @mrfred456123
    @mrfred4561236 ай бұрын

    Amazing explanation

  • @harshinredzone
    @harshinredzone Жыл бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    👍

  • @guptajicodes
    @guptajicodes6 ай бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    6 ай бұрын

    thank you

  • @imranmohamed5467
    @imranmohamed5467 Жыл бұрын

    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

    8 ай бұрын

    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()); } }

  • @saifurrahmanbhuiyan925
    @saifurrahmanbhuiyan925 Жыл бұрын

    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.

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thanks Saifur

  • @sameerchoudhary8590
    @sameerchoudhary85905 ай бұрын

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

  • @parasmyname784
    @parasmyname784 Жыл бұрын

    Awesome, simply awesome

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you

  • @DurgaShiva7574
    @DurgaShiva7574 Жыл бұрын

    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...

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thanks buddy

  • @pranav8937
    @pranav893718 күн бұрын

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

  • @theunusual4566
    @theunusual4566 Жыл бұрын

    Thank you sir for another awesome video.

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank t

  • @harishpareek6933
    @harishpareek6933 Жыл бұрын

    Thank you sir for this Amazing content. I have only one question that for every layer we have to create a new class so if our application will scale too much in that case we might have thousands of layers (Not specifically Pizza problem) so how can we solve that ?

  • @adityarout1276
    @adityarout1276 Жыл бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    :)

  • @sundergopalsingh
    @sundergopalsingh7 ай бұрын

    Amazing video Shrayansh!!

  • @ConceptandCoding

    @ConceptandCoding

    7 ай бұрын

    Thanks paji

  • @simplymaths5487
    @simplymaths5487 Жыл бұрын

    Thanks for this playlist sir. Means a lot to us

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you

  • @your_name96
    @your_name96 Жыл бұрын

    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.

  • @Narendra-Pratap-singh
    @Narendra-Pratap-singh29 күн бұрын

    thanks for the video

  • @prashantgupta6160
    @prashantgupta6160 Жыл бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    thank you Prashant. means lot to me.

  • @sumitbasu5146
    @sumitbasu5146 Жыл бұрын

    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

  • @kalravsharma178
    @kalravsharma178 Жыл бұрын

    Great Video , thanks a lot

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Glad you liked it!

  • @zaheerabass7955
    @zaheerabass795511 ай бұрын

    Thank you so much for the amazing contents

  • @ConceptandCoding

    @ConceptandCoding

    11 ай бұрын

    Thank you

  • @hiren6691
    @hiren66912 жыл бұрын

    keep going :)

  • @amitgupta-or5nm
    @amitgupta-or5nm Жыл бұрын

    Great expansion 😃 ....

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you

  • @Mmmmmkoogfssdvbhvggg
    @Mmmmmkoogfssdvbhvggg7 ай бұрын

    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

    5 ай бұрын

    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.

  • @bhavyemalhotra1584
    @bhavyemalhotra158412 күн бұрын

    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

  • @ayushsamyal9070
    @ayushsamyal9070 Жыл бұрын

    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.

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Noted, will do it from now

  • @utkarshjaiswal7224
    @utkarshjaiswal72242 ай бұрын

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

  • @arshalakhan567
    @arshalakhan567 Жыл бұрын

    Such a great content!:)

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you so much!

  • @naveentmyug
    @naveentmyug7 ай бұрын

    Very thanks

  • @parag-kumar
    @parag-kumar11 ай бұрын

    Great explanation! :)

  • @ConceptandCoding

    @ConceptandCoding

    11 ай бұрын

    Thank you

  • @HEMANTVERMA-pv2pe
    @HEMANTVERMA-pv2pe Жыл бұрын

    Thanks for the great content! Your videos are easy to understand. Can we please reorder the videos in the order, currently its in reverse order and we have to play videos manually each time.

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you, sure let me check

  • @satishkumpatla5848
    @satishkumpatla58484 ай бұрын

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

  • @durgeshrai04
    @durgeshrai04 Жыл бұрын

    Awesome Explantion

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you

  • @user-et1lp1kp4m
    @user-et1lp1kp4m10 ай бұрын

    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..)?

  • @HimanshuKumar-xz5tk
    @HimanshuKumar-xz5tk Жыл бұрын

    great!

  • @nisarggogate8952
    @nisarggogate89522 ай бұрын

    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)

  • @harshilgupta9225
    @harshilgupta9225 Жыл бұрын

    Maza Aagya respect++

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thanks

  • @ShivamVerma-ut6nk
    @ShivamVerma-ut6nk Жыл бұрын

    please make a video on is-a and has-a concept with an example. Its very confusing.

  • @NeverGiveUp186
    @NeverGiveUp186 Жыл бұрын

    Another use case for this pattern is the avatar creation system in WhatsApp/FB

  • @allaboutcricket7728
    @allaboutcricket7728 Жыл бұрын

    Hi Sir, I have 1 question, when both the classes, ExtraCheese and Mushroom have the BasePizza object, then why not add it as part of the ToppingDecorator class itself?

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Ack. Will get back to you by eod

  • @ayushdas17

    @ayushdas17

    Жыл бұрын

    By the Dependency Inversion Principle classes should depend on interfaces or abstract classes rather than concrete classes.

  • @abirpaul9027
    @abirpaul902711 ай бұрын

    Could we have used Builder design Pattern to achieve the same?

  • @nishantkumar6116
    @nishantkumar6116 Жыл бұрын

    Does Response Wrapper that is being used while paasing responses from API also follows decorator pattern?

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    kind of you can say, but thats a good thinking

  • @sloppybug9856
    @sloppybug9856 Жыл бұрын

    Hello sir, first of all thank you for this amazing content ❤.... I hv one question why BasePizza and ToppingDecorator abstract class are abstract classes not interface. ... Just wondering when to use abstract class and when to use interface

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Generally both purpose is same to hide the implementation. Interface provide 100% abstraction, while in abstract class you can also implement some methods which are common to child classes

  • @himanshuchhikara4918
    @himanshuchhikara49184 ай бұрын

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

  • @soumakpoddar4372
    @soumakpoddar43722 ай бұрын

    can we not use interfaces instead of abstract classes ?

  • @shreyashachoudhary480
    @shreyashachoudhary480 Жыл бұрын

    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

  • @uuujjwalsquare8991
    @uuujjwalsquare89913 ай бұрын

    What if we directly extend base class inplace of topper decorator

  • @vivekthakur1953
    @vivekthakur1953 Жыл бұрын

    You should create video where you clearly stat the differences between "HAS- A" and "IS -A" relationship which will help many people

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    I think in 1 video i did that Vivek, if not then do check the first video of "Live LLD" playlist in that i must have explained it

  • @ananddidwania3799

    @ananddidwania3799

    Жыл бұрын

    Here is the timestamp kzread.info/dash/bejne/X4mezMizepidZNo.html to understand "IS-A" and "HAS-A" relationship

  • @pulakammalathy6968
    @pulakammalathy69687 күн бұрын

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

  • @AbhilashPareek
    @AbhilashPareek Жыл бұрын

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

  • @ayushjain7748

    @ayushjain7748

    Ай бұрын

    Exactly. I have the same question in my mind.

  • @shatrudhankumar7824
    @shatrudhankumar78244 ай бұрын

    Awesome😍

  • @ConceptandCoding

    @ConceptandCoding

    4 ай бұрын

    Thanks

  • @litcode702
    @litcode702 Жыл бұрын

    can't we pass ToppingDecorator object in extraCheese or mushroom constructor?

  • @gunjanyadu865
    @gunjanyadu865 Жыл бұрын

    Hi great videos. Can you please share the notes or code that you writing ? Moreover, when will the whole LLD playlist be completed? Eagerly waiting to complete all.

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    When it will be completed it will be difficult for me to say. I am going with 1 video a week for now. But i am consistent

  • @Suryabasettydustin
    @Suryabasettydustin Жыл бұрын

    I could be wrong but, can this problem of multiple object permutations be solved by builder pattern also?

  • @kavyababu7

    @kavyababu7

    10 ай бұрын

    I have the same question. Since the Pizza problem comes more in a object creational use case, wouldn't builder pattern fit more for this use case. Decorators are used to modify the functionality of an object in runtime. Using decorator for object creation puts the object in an inconsistent state till all the decorators are completed. In real scenarios, decorator would be useful, when we need to stack up the operations like encoding a file and then compressing etc.

  • @rahulbera454
    @rahulbera454 Жыл бұрын

    So according to my understanding we use decorator pattern for incrementally include or not include features. Can't this be also achieved with builder pattern ??? Can you briefly compare the tradeoffs ( with reply to this comment ), Thank you.

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Ack.

  • @developerDebanjan
    @developerDebanjan6 ай бұрын

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

  • @vibhavagarwal9968
    @vibhavagarwal99686 ай бұрын

    Hello sir, thanks for the amazing content. I have one question, in the above implementation instead of creating a decorator class, cant we directly extend BasePizza class for ExtraCheese/Mushroom classes? I think there is something fundamentally wrong in this, but not sure what exactly 😅

  • @ConceptandCoding

    @ConceptandCoding

    5 ай бұрын

    just think of combinations of chesse. mushroom and just with base pizza itself. now if there are 10 types of decorator and multiple base pizza, then no of combinations would be large and you will end up creating lot and lot of classes. thats what decorator pattern saves us. try to implement what you mentioned and you will get to know

  • @kartikag01
    @kartikag013 ай бұрын

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

  • @kushal7966
    @kushal796610 ай бұрын

    Thank You

  • @ConceptandCoding

    @ConceptandCoding

    10 ай бұрын

    Thank you

  • @vennamurthy
    @vennamurthy Жыл бұрын

    Strategy Pattern & Decorator seems alike to me like IStrategy even BasePizza Can have only HAS-A relation with ToppingDecorator or list (to calculate cost for all types of toppings) right. Please help me to understand the difference , By the way thanks for the videos :) #Concept&&Coding

  • @ayushdas17

    @ayushdas17

    Жыл бұрын

    I think main task of Strategy Pattern is to remove redundant code where as Decorator Pattern is used to solve the problem of maintainability of our classes.

  • @ksaloni
    @ksaloni7 ай бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    7 ай бұрын

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

  • @NeverGiveUp186
    @NeverGiveUp186 Жыл бұрын

    Hello Sir, first of all thank you very much for the amazing content! I have one doubt. For interviews, are all the design patterns necessary ? Becoz it would be difficult to remember all of them 😅.. How much is expected from us if we have 2-3 years experience ?

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you. See it's a very valid question, nobody can remember all these designs patterns. Couple of things: - How many design patterns is sufficient? Very difficult to answer, what interviewer can ask, we don't know right. - How to remember all? We don't have to, just try to implement design patterns with your own examples, whatever examples i used take it as a reference and then try to implement with different example. It will help you to remember in which usecase what has to be done. Keep 5-6 design patterns on your finger tips which is very frequently asked.

  • @NeverGiveUp186

    @NeverGiveUp186

    Жыл бұрын

    @@ConceptandCoding Thanks a lot Sir for the quick and detailed response!!

  • @sagarbiradar1104
    @sagarbiradar1104 Жыл бұрын

    You are awesomeee🔥🔥❤

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Thank you

  • @sagarbiradar1104

    @sagarbiradar1104

    Жыл бұрын

    @@ConceptandCoding

  • @travelwsamad
    @travelwsamad5 ай бұрын

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

  • @ConceptandCoding

    @ConceptandCoding

    5 ай бұрын

    :)

  • @user-vn5hk5gs3n
    @user-vn5hk5gs3n11 ай бұрын

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

  • @shyren_more

    @shyren_more

    10 ай бұрын

    had the same question

  • @devashishrana1637
    @devashishrana16377 ай бұрын

    I was thinking, can the Pizza example be considered as a builder pattern as well? Even in this each toppings can be separate methods? Can you clear me on this? Thanks for the really amazing Videos!!

  • @ConceptandCoding

    @ConceptandCoding

    7 ай бұрын

    try it out once. I think it can be done, but need to check.

  • @doingsneakypeakylike
    @doingsneakypeakylike Жыл бұрын

    Hi. Thanks for the explanation. I have a question. Can't we use a builder pattern to create different toppings on the pizza or add different features to a car? If decorator pattern is a better pattern to do it, can you please explain why? My thought process is that builder pattern is good for making pizza because once a pizza is ordered you don't need to give customer the flexibility to change it after placing the order. Can you please let me know what you think? Thank you once again.

  • @souvikpodder9515

    @souvikpodder9515

    Жыл бұрын

    +1 I am even having the same doubt. So, I too feel if some clarity is provided by the author would be helpful. With my understanding, I feel with this pattern we will not violate Open/Closed Principal because whenever there will be new topping, we can add a separate base class whereas in builder pattern we will be modifying the builder class to add the new toppings.

  • @ashish261096

    @ashish261096

    Жыл бұрын

    I also had the same doubt, but in Pizza scenario I think it would be correct to use Decorator pattern since we don't get the all the topping details at the start itself, user may add topping or may not. So this pattern will be used if the object(Pizza) is already created and after that we need to add new features(topppings) basically at run time we are adding new features to existing object. Builder pattern will be used if we have all the details at the start itself while creating Object.

  • @shubhamshah2125

    @shubhamshah2125

    Жыл бұрын

    IMO.. You can also have toppings and types of pizza inside pizza.. but decorator pattern is used when you don't want to modify existing object and want to add functionality only.. ex: pizza won't always have toppings..it needs it only for cost computation.. so why have it inside pizza.. classic examples are Java Streams

  • @shubhamtrivedi2155
    @shubhamtrivedi2155Ай бұрын

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

  • @geetikapaul5071
    @geetikapaul507111 ай бұрын

    Thanks for the videos. I have a question: why did you use an abstract class? Could we use interface instead?

  • @ConceptandCoding

    @ConceptandCoding

    11 ай бұрын

    yes, we can if you dont have a usecase where you have to implement common method , then interface is good too.

  • @geetikapaul5071

    @geetikapaul5071

    11 ай бұрын

    Thank you for the prompt response!

  • @preethisubbu7460
    @preethisubbu746011 ай бұрын

    Adding English subtitle would be really helpful for larger community.

  • @ConceptandCoding

    @ConceptandCoding

    11 ай бұрын

    Yes will work on old video, but all latest videos are in English only

  • @akhilsharma1778
    @akhilsharma1778 Жыл бұрын

    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

    Жыл бұрын

    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

  • @DevanshChiluka
    @DevanshChiluka3 ай бұрын

  • @anirbansaha7987
    @anirbansaha79877 ай бұрын

    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

    7 ай бұрын

    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

    7 ай бұрын

    @@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 ?

  • @anjumanislamiachhatarpur7093
    @anjumanislamiachhatarpur7093 Жыл бұрын

    I have a question, when we create the base parent class... how we can decide to take interface or abstract. I think both will work fine. So which one to choose in that case, could you please give a little clearity.?

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    If you want some method to implement in base class which child can reuse, then go for abstract else interface.

  • @anjumanislamiachhatarpur7093

    @anjumanislamiachhatarpur7093

    Жыл бұрын

    @@ConceptandCoding tysm 🙏

  • @FitMitDiary
    @FitMitDiary Жыл бұрын

    Let's say if we have a simple case as a Pizza then instead of abstract class for Base Pizza, can we use interface ?

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    Yes we can, if you don't want to implement any common method in that

  • @AnuragSharma-vi1zd
    @AnuragSharma-vi1zd Жыл бұрын

    Hello sir I have a question. What if now we want to remove the toppings we added. How we can do that?

  • @ConceptandCoding

    @ConceptandCoding

    Жыл бұрын

    We can call the topping decorator only right

  • @prashantkumar-hx1dv
    @prashantkumar-hx1dv7 ай бұрын

    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

    7 ай бұрын

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

  • @imranzafar3653
    @imranzafar36535 күн бұрын

    I tried and understood and thought do I need abstract classes here cant I just use one Interface like BasePizza and implement it in my Base classes such as vegPizza and implement the same interface in topping classes but one chnage my topping class constructor should accept a BasePizza type Object; BasePizza pizza = new Extracheese(new Margherita());

  • @singhji4149
    @singhji41499 ай бұрын

    One very important question sir ji, when to interfere and when to use abstract can u make a detailed video in this, i think this will solve many questions of LLD in a thinking way

  • @ConceptandCoding

    @ConceptandCoding

    9 ай бұрын

    When you want 100% abstraction go for interface, else go for Abstract class

  • @singhji4149

    @singhji4149

    9 ай бұрын

    Yes, i know this, but while in interview when we say that i will create an abstract class or interface or concrete class they always ask why so? Why not interface inplace of abstract class, this is has been asked alot. So just a request when ever u make any any interface or abstract class please tell us the why interface or abstract please 🙏

Келесі