No video

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

  Рет қаралды 81,040

Concept && Coding - by Shrayansh

Concept && Coding - by Shrayansh

Күн бұрын

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

Пікірлер: 320
@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
@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 😊
@patrisrikanth
@patrisrikanth 7 ай бұрын
Unbelievable that we are getting this video for free of cost.... Awesome explanation.
@kartikag01
@kartikag01 5 ай бұрын
bhai ne kuch videos paid kr di 😁
@sagar1691
@sagar1691 7 ай бұрын
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.
@AgeofBelief
@AgeofBelief 6 ай бұрын
Just can not believe that this piece of gem is free on youtube !! Really appreciate your efforts. :)
@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
@navdeepkaushik218
@navdeepkaushik218 Ай бұрын
Please dont make this channel paid ..it best channel in youtube at present time to understand lld concepts ...
@TECH_PANDA_23
@TECH_PANDA_23 5 ай бұрын
very good explanation is the best, simplicity is the base here and visual representation is toppings
@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 Жыл бұрын
:)
@adhyanneekhra4853
@adhyanneekhra4853 3 ай бұрын
🤯🤯🤯🤯🤯 Swaad hi agya 😋😋😋😛. Thanks Shreyansh for this Amazing vedio series. Great content. And Beautifully explained.
@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
@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
@VinayakKhairnar-bb7oc
@VinayakKhairnar-bb7oc 3 ай бұрын
'Has a' and 'is a' make concept much simpler to understand. Good point you make to explain.
@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.
@tarunkundhiya5196
@tarunkundhiya5196 Жыл бұрын
Nice point : both isA and hasA property is needed! Awesome Explanation!
@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!
@harshinredzone
@harshinredzone Жыл бұрын
Thanks for sorting it in "reverse" order. Glad that you considered the feedback. 😀
@ConceptandCoding
@ConceptandCoding Жыл бұрын
👍
@hbolchatwar5308
@hbolchatwar5308 Жыл бұрын
Very good explanation with code...u did awesome job. really thanks a lot.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
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 10 ай бұрын
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()); } }
@shawkiahmed3586
@shawkiahmed3586 Ай бұрын
Thanks for the explanation with the examples.
@prashantgupta6160
@prashantgupta6160 Жыл бұрын
thoda nhi, bahut useful h bhai, please continue LLD series, you are one of best educators on KZfaq
@ConceptandCoding
@ConceptandCoding Жыл бұрын
thank you Prashant. means lot to me.
@CodeBoost8375
@CodeBoost8375 Ай бұрын
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.❤❤
@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
@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
@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
@sravanakirtana2787
@sravanakirtana2787 4 ай бұрын
Awesome explanation Sir. Thank you very much
@utkarshjaiswal7224
@utkarshjaiswal7224 4 ай бұрын
Can we use interface instead of abstract class..I both in this case both will work fine
@Rabbitv-r8s
@Rabbitv-r8s Жыл бұрын
Awesome explanation
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@theunusual4566
@theunusual4566 Жыл бұрын
Thank you sir for another awesome video.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank t
@sundergopalsingh
@sundergopalsingh 9 ай бұрын
Amazing video Shrayansh!!
@ConceptandCoding
@ConceptandCoding 9 ай бұрын
Thanks paji
@realthings7931
@realthings7931 Жыл бұрын
Great Explanation. Thanks for the video🙏
@ConceptandCoding
@ConceptandCoding Жыл бұрын
thank you
@praveenkrdas72
@praveenkrdas72 5 ай бұрын
Great job Shrayansh .
@guptajicodes
@guptajicodes 7 ай бұрын
I really understood this design pattern. thank you sir for wonderful explaination
@ConceptandCoding
@ConceptandCoding 7 ай бұрын
thank you
@pranav8937
@pranav8937 2 ай бұрын
J is silent in jalapeno😅. Rest video was awesome!!
@ankitkumaryadav562
@ankitkumaryadav562 Ай бұрын
Very helpfull video
@simplymaths5487
@simplymaths5487 Жыл бұрын
Thanks for this playlist sir. Means a lot to us
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@parasmyname784
@parasmyname784 Жыл бұрын
Awesome, simply awesome
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@travelwsamad
@travelwsamad 7 ай бұрын
Others : Learning Decorator Pattern from this Video Meanwhile me -> Learning and Ordering a Margarita Pizza after watching 😂
@ConceptandCoding
@ConceptandCoding 7 ай бұрын
:)
@amitgupta-or5nm
@amitgupta-or5nm Жыл бұрын
Great expansion 😃 ....
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@sachhai797
@sachhai797 7 ай бұрын
//non decorator BasePizza p= new Margherita(); Topping t1= new ExtraCheese(); Topping t2 = new Veggies(); Topping t3= new Paneer(); Topping t4= new mushroom(); string tot = updateDesc(p.desc(), t1.desc()); tot = updateDesc(tot, t2.desc()); tot = updateDesc(tot, t3.desc()); tot = updateDesc(tot, t4.desc()); updateDesc(total,desc){ return total+ desc } //decorator BasePizza p= new Margherita(); p = new ExtraCheese(p) p = new Veggies(p) p = new Paneer(p) p = new mushroom(p) p.getdesc()
@shineinusa
@shineinusa Ай бұрын
faad diya bhai
@ayushigupta685
@ayushigupta685 6 ай бұрын
I really appreciate your efforts thankyou so much😇😇😇😇👏👏👏👏👏
@princesharma-wi3kn
@princesharma-wi3kn 3 ай бұрын
Thank you so much for the detailed explanation :)
@homestaysandcafes
@homestaysandcafes 2 жыл бұрын
Very Well explained sir!
@kalravsharma178
@kalravsharma178 Жыл бұрын
Great Video , thanks a lot
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Glad you liked it!
@Narendra-Pratap-singh
@Narendra-Pratap-singh 2 ай бұрын
thanks for the video
@akshaymahajan9626
@akshaymahajan9626 6 ай бұрын
Great work !
@parag-kumar
@parag-kumar Жыл бұрын
Great explanation! :)
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@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
@sameerchoudhary8590
@sameerchoudhary8590 6 ай бұрын
Great explanation. But I need to revisit the example once again.
@himanshuchhikara4918
@himanshuchhikara4918 5 ай бұрын
why you used abstract class , can we use interfaces also ?
@shatrudhankumar7824
@shatrudhankumar7824 6 ай бұрын
Awesome😍
@ConceptandCoding
@ConceptandCoding 6 ай бұрын
Thanks
@NeverGiveUp186
@NeverGiveUp186 Жыл бұрын
Another use case for this pattern is the avatar creation system in WhatsApp/FB
@hardik_aswal
@hardik_aswal 29 күн бұрын
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.
@umangmalhotra1222
@umangmalhotra1222 Жыл бұрын
2023 New Year Resolution -> Watching 1 video from Concept && Coding YT Channel everyday . Update -> Finished this 4th video in LLD Playlist today.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Hope you will find the content useful 🙏
@zaheerabass7955
@zaheerabass7955 Жыл бұрын
Thank you so much for the amazing contents
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@durgeshrai04
@durgeshrai04 Жыл бұрын
Awesome Explantion
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@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
@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.
@dakshisuri6776
@dakshisuri6776 13 күн бұрын
I am slightly confused that why have we created an extra abstract class called ToppingsDecorator. We could have easily inherited base pizza class while creating a toppings pizza like "ExtraCheese". Since there are no methods to implement in abstract ToppingsDecorator its importance is not clear yet.
@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 ?
@princesharma-wi3kn
@princesharma-wi3kn 2 ай бұрын
Apne saraswatya mantra liya hua hai kya bro🥰
@naveentmyug
@naveentmyug 8 ай бұрын
Very thanks
@sagarbiradar1104
@sagarbiradar1104 Жыл бұрын
You are awesomeee🔥🔥❤
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you
@sagarbiradar1104
@sagarbiradar1104 Жыл бұрын
@@ConceptandCoding
@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.
@harshilgupta9225
@harshilgupta9225 Жыл бұрын
Maza Aagya respect++
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thanks
@MayankLC93
@MayankLC93 2 ай бұрын
IN CPP #include using namespace std; // Base class class BasePizza { public: virtual int cost() const = 0; // Pure virtual function virtual ~BasePizza() = default; // Virtual destructor for proper cleanup }; // Concrete components class Margherita : public BasePizza { public: int cost() const override { return 100; } }; class VeggieDelight : public BasePizza { public: int cost() const override { return 200; } }; // Base Decorator class Toppings : public BasePizza { protected: BasePizza* basePizza; public: Toppings(BasePizza* base) : basePizza(base) {} virtual ~Toppings() { delete basePizza; // Ensure the base pizza object is deleted to prevent memory leaks } }; // Concrete Decorators class ExtraCheese : public Toppings { public: ExtraCheese(BasePizza* base) : Toppings(base) {} int cost() const override { return basePizza->cost() + 20; } }; class Mushroom : public Toppings { public: Mushroom(BasePizza* base) : Toppings(base) {} int cost() const override { return basePizza->cost() + 40; } }; int main() { // Creating a Margherita pizza with extra cheese BasePizza* pizza = new ExtraCheese(new Margherita()); cout
@preethisubbu7460
@preethisubbu7460 Жыл бұрын
Adding English subtitle would be really helpful for larger community.
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Yes will work on old video, but all latest videos are in English only
@arshalakhan567
@arshalakhan567 Жыл бұрын
Such a great content!:)
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Thank you so much!
@hiren6691
@hiren6691 2 жыл бұрын
keep going :)
@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
@samyakjain8079
@samyakjain8079 4 ай бұрын
Duplication in cheese and mushroom
@harshpandey6799
@harshpandey6799 Ай бұрын
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 ?
@AbhilashPareek
@AbhilashPareek Жыл бұрын
ExtraCheese and mushroom can also extend basePizza right? Why do we have another abstract class in between?
@ayushjain7748
@ayushjain7748 3 ай бұрын
Exactly. I have the same question in my mind.
@satishkumpatla5848
@satishkumpatla5848 6 ай бұрын
Please explain when to use decorator pattern and builder design pattern and differemces. Both seems similar.
@nisarggogate8952
@nisarggogate8952 4 ай бұрын
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)
@singhji4149
@singhji4149 11 ай бұрын
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 11 ай бұрын
When you want 100% abstraction go for interface, else go for Abstract class
@singhji4149
@singhji4149 11 ай бұрын
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 🙏
@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 kzfaq.info/get/bejne/Y7uancmrr5ubZKs.html to understand "IS-A" and "HAS-A" relationship
@imranzafar3653
@imranzafar3653 Ай бұрын
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());
@geekydanish5990
@geekydanish5990 2 жыл бұрын
I feel an improvment to this can be rather than creating concrete class for each topping create enum topping list class to dynamically update price for each topping
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
can you implement and show how for the same example which i took.
@geekydanish5990
@geekydanish5990 2 жыл бұрын
@@ConceptandCoding sure
@geekydanish5990
@geekydanish5990 2 жыл бұрын
from __future__ import annotations from abc import ABC, abstractmethod import enum import string from typing import List class ToppingList(enum.Enum): extra_cheese = 20.00 jalapeno = 30.00 mushroom = 10.00 chicken_tikka = 60.00 class BasePizza(ABC): @abstractmethod def get_ingregents(self) -> List: pass @abstractmethod def cost(self) -> float: pass # concrete pizza class class MargaritaPizza(BasePizza): ingredients: List = ['Cheese','Bread','Olive Oil'] def get_ingregents(self) -> List: return self.ingredients def cost(self) -> float: return 150.00 class VeggiePizza(BasePizza): ingredients: List = ['Cheese','Bread','Olive Oil','Veggies'] def get_ingregents(self) -> List: return self.ingredients def cost(self) -> float: return 200.00 class Topping(BasePizza): _base_pizza: BasePizza = None def __init__(self,base_pizza: BasePizza, topping:string) -> None: self._base_pizza = base_pizza self._topping = topping def get_ingregents(self) -> List: base_ingregents = self._base_pizza.get_ingregents() base_ingregents.append(self._topping) return base_ingregents def cost(self) -> float: return self._base_pizza.cost() + ToppingList[self._topping].value if __name__ == '__main__': base_pizza = MargaritaPizza() margarita_pizza_extra_cheese = Topping(base_pizza,'extra_cheese') print(margarita_pizza_extra_cheese.get_ingregents()) print(margarita_pizza_extra_cheese.cost()) margarita_pizza_extra_cheese_jalapeno = Topping(margarita_pizza_extra_cheese,'jalapeno') print(margarita_pizza_extra_cheese_jalapeno.get_ingregents()) print(margarita_pizza_extra_cheese_jalapeno.cost())
@geekydanish5990
@geekydanish5990 2 жыл бұрын
@@ConceptandCoding Hey does the below solution follow any anti pattern wrt to decorator design pattern
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
this code still maintains 'is-a' and 'has-a' relationship. So that is the requirement of decorator pattern . But here my concern with enum is not decorator pattern but with scalability and managebility lets say i want to add more methodd apart from Cost method like TotalCalories, totalProtein , totalCarbs etc. (lets say 10 -20 methods like this) how easy with enum to support this.
@namanjain2488
@namanjain2488 11 ай бұрын
why u need decorator ? to save from class explosion as there can be many combination of class like margeta pizza+ cheese , onion +tamota etc
@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
@dileepkumareduvaka4864
@dileepkumareduvaka4864 Ай бұрын
what was the use of declaring the has a in toppings[ extraCheese] , are we using it some where?
@DevanshChiluka
@DevanshChiluka 4 ай бұрын
@user-vn5hk5gs3n
@user-vn5hk5gs3n Жыл бұрын
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 Жыл бұрын
had the same question
@pulakammalathy6968
@pulakammalathy6968 Ай бұрын
why is base pizza and topping decorator abstarct classes ? can they be interfaces? Iam not able to justify this point properly
@Mmmmmkoogfssdvbhvggg
@Mmmmmkoogfssdvbhvggg 9 ай бұрын
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 7 ай бұрын
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.
@ShivamVerma-ut6nk
@ShivamVerma-ut6nk Жыл бұрын
please make a video on is-a and has-a concept with an example. Its very confusing.
@kaustubhdixit8278
@kaustubhdixit8278 5 ай бұрын
Wouldn’t builder pattern be a better approach? Moreover decorator pattern adds functionality to an already existing class, With each new topping/variant a new decorator has to be created…
@kaustubhdixit8278
@kaustubhdixit8278 5 ай бұрын
We could have added a list( of class Toppings i.e, superclass for each type of topping) to our pizza class, With decorator pattern used for less variation like veg/ non-veg pizza….?
@user-et1lp1kp4m
@user-et1lp1kp4m 11 ай бұрын
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..)?
@BeyondTheFamiliar_2023
@BeyondTheFamiliar_2023 2 жыл бұрын
Wonderfully explained!! Its more like recurssion, so if imagine there are 100 of layes of decorator, then there might be overlapping subproblems. Can dp be used in that case?
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
i won't say its a Recursion, to me its looks like more of a hierarchy. Child-> Parent -> Parent ---> likewise
@BeyondTheFamiliar_2023
@BeyondTheFamiliar_2023 2 жыл бұрын
@@ConceptandCoding but a child might not replicate the same behaviouras that of parent.
@ConceptandCoding
@ConceptandCoding 2 жыл бұрын
@@BeyondTheFamiliar_2023 ummm Why not, in inheritance, child has its Parent capabilities+ additionally its own.
@meme_engineering4521
@meme_engineering4521 2 жыл бұрын
har jaga dsa ghusa do matlab
@chaitanyaprasad6924
@chaitanyaprasad6924 6 ай бұрын
This has a problem!! Assume that a class has other methods after it is decorated we can't access them ?
@patrisrikanth
@patrisrikanth 7 ай бұрын
Hi, I understood this clearly, But I have a small doubt regarding Abstract class vs Interface. Can't we use Interface in BasePizza and ToppingDecorator, rather than using Abstract class? Other than this, I understood everything. Super explanation sir.
@vmalhotra98
@vmalhotra98 6 ай бұрын
same question . Can anyone explain same @Concept && Coding - by Shrayansh
@NitinKumar-gv4hs
@NitinKumar-gv4hs Жыл бұрын
Can you explain what does has-a keyword mean , here ? @13:34
@ConceptandCoding
@ConceptandCoding Жыл бұрын
Ack
@NitinKumar-gv4hs
@NitinKumar-gv4hs Жыл бұрын
@@ConceptandCoding I didn't understood, had had one doubt could we do this by creating interfaces as well ?
@bhavyemalhotra1584
@bhavyemalhotra1584 2 ай бұрын
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
@anirbansaha7987
@anirbansaha7987 9 ай бұрын
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 9 ай бұрын
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 9 ай бұрын
@@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 ?
@dhruvsinghal6451
@dhruvsinghal6451 Ай бұрын
Cant we just add that feature when it comes into that class , if someone wants to use that may use it they have the option otherwise it will be 0 like extra veggies can be initiated to 0 for those who dont want to use it
@fueLInjected29
@fueLInjected29 Жыл бұрын
Okay, I ordered the PIZZA! (Margherita + Extra Cheese)
@venkateshchakravarti2817
@venkateshchakravarti2817 23 күн бұрын
Doesn't the constructing i.e nesting objects inside is still complex? I mean calling those extra features still looks complex.
@HimanshuKumar-xz5tk
@HimanshuKumar-xz5tk Жыл бұрын
great!
5. Factory Pattern Vs Abstract Factory Pattern Explanation, Low Level System Design interview
12:19
How I Did The SELF BENDING Spoon 😱🥄 #shorts
00:19
Wian
Рет қаралды 36 МЛН
Kids' Guide to Fire Safety: Essential Lessons #shorts
00:34
Fabiosa Animated
Рет қаралды 14 МЛН
КАКУЮ ДВЕРЬ ВЫБРАТЬ? 😂 #Shorts
00:45
НУБАСТЕР
Рет қаралды 3,2 МЛН
لااا! هذه البرتقالة مزعجة جدًا #قصير
00:15
One More Arabic
Рет қаралды 51 МЛН
3. Observer Design Pattern Explanation, Walmart Design Interview Question, 2022 | LLD System Design
34:34
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 250 М.
What is the Decorator Pattern? (Software Design Patterns)
19:41
Be A Better Dev
Рет қаралды 25 М.
19. Design File System using Composite Design Pattern | Low Level Design Interview Question | LLD
21:30
How I Mastered Low Level Design Interviews
8:41
Ashish Pratap Singh
Рет қаралды 61 М.
How I Did The SELF BENDING Spoon 😱🥄 #shorts
00:19
Wian
Рет қаралды 36 МЛН