{"id":30100,"date":"2022-11-25T18:21:41","date_gmt":"2022-11-25T12:51:41","guid":{"rendered":"https:\/\/blazeclan.com\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/"},"modified":"2023-03-06T15:25:47","modified_gmt":"2023-03-06T09:55:47","slug":"simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use","status":"publish","type":"post","link":"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/","title":{"rendered":"Simplifying Coding with the Decorator Design Pattern \u2013 When To &amp; When Not to Use it!"},"content":{"rendered":"<p>As&nbsp; explained in my&nbsp;previous Blog, &nbsp;if you are working with group of developers &nbsp;or individually implementing proper design concepts like the&nbsp;Singleton Design Pattern, you don\u2019t have to spend time explaining the intricacies of a your solution. &nbsp;If you are familiar with the Singleton pattern, you are much further along in the design process path. However, you need to know which Design Patterns fit the bill for the right solution for your Code. in the Singleton Example of the President in the last blog, that design pattern fit perfectly. But if you try to apply Singleton in the Pizza Solution example we\u2019ll be discussing in this blog, it won\u2019t work; so let us see how the Decorator Design Pattern Works with&nbsp;<strong>Code Snippets to help you through!&nbsp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h3>Decoding the Decorator ! What is It &amp; why Isn\u2019t Anyone Using it?<\/h3>\n<p>The&nbsp;<b>Decorator Design&nbsp;pattern&nbsp;<\/b>is a prominent core Java design&nbsp;pattern&nbsp;and you can see many examples of it in JDK itself. JDK uses decorator&nbsp;patterns in the IO package where it has decorated the Reader and Writer Classes for various scenarios. BufferedReader and BufferedWriter are example of&nbsp;decorator design&nbsp;patterns in Java. So what is the Decorator Pattern &amp; why Isn\u2019t anyone using it?<span id=\"more-2078\"><\/span><\/p>\n<p>Well, the Decorator pattern is very important to understand because once you know the techniques of decorating, you\u2019ll be able to give your objects new responsibilities without making any code changes to the underlying classes. The Decorator Pattern allows class behavior to the decorated dynamically. It\u2019s a structural design pattern as it\u2019s used to form large object structures across many disparate objects. The concept of decorator is that&nbsp;it adds additional attributes to an object dynamically.<\/p>\n<p>The original definition provided in&nbsp;original Gang of Four book on Design Patterns states:<\/p>\n<pre><em>Allows for the dynamic wrapping of objects in order to modify their existing responsibilities and behaviors&nbsp;\n<strong>Decorator pattern achieves a single objective of dynamically adding responsibilities to any object.<\/strong>\n<\/em><\/pre>\n<p>&nbsp;<\/p>\n<h3>So When is it Right to Use the Decorator Pattern ?<\/h3>\n<p>I found that Decorator Design Pattern has several requirement indicators to suggest that it is potential solution e.g.<\/p>\n<ul>\n<li>When we have an object that requires the extension ex. a window control that requires additional \u201coptional\u201d features like scrollbars, titlebar and statusbar.<\/li>\n<li>When Several objects that support the extension by \u201cdecoration\u201d. Usually, those objects share a common interface, traits, or superclass, and sometimes, additional, intermediate super-classes .<\/li>\n<li>The decorated object (class or prototype instantiation), and the decorator objects have one or several common features. In order to ensure that functionality, the decorated object &amp; the decorators have a common interface, traits, or class inheritance.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3>Why do we use the decorator design pattern? Pizzas to the Rescue !<\/h3>\n<p>The answer is if anyone wants to add some functionality to an individual object or change the state of a particular object at the run time it\u2019s not possible to provide the specific behavior to all the objects of that class at the design time by the help of inheritance or using subclasses, but&nbsp;<b>Decorator pattern<\/b>&nbsp;makes it possible to provide individual objects of the same class a specific behavior or state at the run time. This doesn\u2019t affect other objects of the same java class<\/p>\n<p>Consider a case of a pizza shop. A pizza shop will sell few pizza varieties and they will also provide a range of toppings in the menu. Now imagine a situation wherein if the pizza shop has to provide prices for each combination of pizza and topping. Even if there are&nbsp;<strong>four basic<\/strong>&nbsp;pizzas and&nbsp;<strong>8 different<\/strong>&nbsp;toppings, the application would go crazy maintaining all these concrete combination of pizzas and toppings.<\/p>\n<p><strong>In comes the Decorator Pattern:&nbsp;<\/strong><\/p>\n<p>As per this, you will implement toppings as decorators and pizzas will be decorated by those toppings\u2019 decorators. Practically each customer would want toppings of his desire and final bill-amount will be composed of the base pizzas and additionally ordered toppings. Each topping decorator would know about the pizzas that it is decorating and it\u2019s price. GetPrice() method of Topping object would return cumulative price of both pizza and the topping.<\/p>\n<p>Here\u2019s a code-example of explanation above.<\/p>\n<p>Decorator Pattern Example<\/p>\n<pre><span style=\"color: #ff6600;\">The below is an interface depicting an Pizza. I have kept things as simple as possible so thatthe focus will be on understanding the design pattern.<\/span>\n\ninterface Pizza { \n    int getPrice();\n}<\/pre>\n<pre><span style=\"color: #ff6600;\"> Following class is a concrete implementation of this interface. This is the base class on     which the decorators will be added.<\/span>\n\nclass PlainPizza implements Pizza {\n\n @Override\n public int getPrice() {\n      return 50;\n }\n}<\/pre>\n<pre><span style=\"color: #ff6600;\">Following class is the decorator class. It is the core of the decorator design pattern. It    contains an attribute for the type of interface. Instance is assigned dynamically at the      creation of decorator using its constructor. Once assigned that instance method will be       invoked.<\/span>\n\nabstract class ToppingDecorator implements Pizza {\n Pizza toppingPizza;\n  public ToppingDecorator(Pizza toppindPizza) { \n   this.toppingPizza = toppindPizza; \n }\n<strong>}<\/strong><\/pre>\n<p><strong><span style=\"color: #ff6600;\">Following three classes are similar. These are three decorators, concrete class implementing the abstract decorator.<\/span><\/strong><\/p>\n<pre>&nbsp;class CheeseToppings extends ToppingDecorator {\n\n public CheeseToppings(Pizza toppindPizza) { \n    super(toppindPizza);\n }\n\n @Override public int getPrice() { \n    return this.toppindPizza.getPrice()+20; \n<em id=\"__mceDel\"> }\n<\/em><em id=\"__mceDel\">}<\/em><\/pre>\n<pre>class ChickenToppings extends ToppingDecorator {\n\n<em id=\"__mceDel\"> public ChickenToppings(Pizza toppindPizza) {<\/em><em id=\"__mceDel\"> \n  super(toppindPizza);<\/em><em id=\"__mceDel\"> \n }\n\n<\/em><em id=\"__mceDel\"> @Override<\/em><em id=\"__mceDel\"> \n public int getPrice() {<\/em><em id=\"__mceDel\"> \n  return this.toppindPizza.getPrice()+ 15;<\/em><em id=\"__mceDel\"> \n }\n<\/em><em id=\"__mceDel\">}<\/em><\/pre>\n<pre>class MushroomsToppings extends ToppingDecorator {\n\n<em id=\"__mceDel\"> public MushroomsToppings(Pizza toppindPizza) {<\/em><em id=\"__mceDel\"> \n   super(toppindPizza);\n<\/em><em id=\"__mceDel\"> }\n\n<\/em><em id=\"__mceDel\">  @Override<\/em><em id=\"__mceDel\"> \n  public int getPrice() {<\/em><em id=\"__mceDel\"> \n     return this.toppindPizza.getPrice()+25;<\/em><em id=\"__mceDel\"> \n  }\n<\/em><em id=\"__mceDel\">}<\/em><\/pre>\n<pre>public class DecoratorDemo {\n public static void main(String[] args) {\n Pizza pizza=new PlainPizza();\n System.out.println(\"Plain Pizza Rs.\"+ pizza.getPrice());\n\n pizza=new CheeseToppings(pizza);\n System.out.println(\"Pizza with Cheese Toppings Rs.\"+ pizza.getPrice());\n\n pizza=new ChickenToppings(pizza);\n System.out.println(\"Pizza with Cheese and Chicken Toppings Rs.\"+pizza.getPrice());\n\n pizza=new MushroomsToppings(pizza);\n System.out.println(\"Pizza with Cheese, Chicken and Mushroom Toppings Rs.\"+pizza.getPrice());\n }\n\n}<\/pre>\n<p><span style=\"color: #ff6600;\"><strong><em>Output:<\/em><\/strong><\/span><\/p>\n<p>Plain Pizza Rs.50<br \/>\nPizza with Cheese Toppings Rs.70<br \/>\nPizza with Cheese and Chicken Toppings Rs.90<br \/>\nPizza with Cheese, Chicken and Mushroom Toppings Rs.115<\/p>\n<p>&nbsp;<\/p>\n<h3>Simplifying Web Services Development with the Decorator Pattern<\/h3>\n<p>Developing Web services can be complex. Even more complex can be designing Web services implementations that allow you to reuse common code and abstract common functionality. The decorator pattern is a flexible way to layer functionality onto your services without having to go through the costly code\/test\/deploy cycle. Developing custom steps and deploying them in policies simplifies your Web services project by freeing your developers to focus on business functionality and not just boilerplate code.<\/p>\n<p>&nbsp;<\/p>\n<h3>So is there an Issue with the Decorator Pattern?<\/h3>\n<p>The Decorator pattern is best when the decorators modify the behavior of the methods in the interface. A decorator can add methods, but added methods don\u2019t carry through when you wrap in another decorator.<\/p>\n<p>In this example, indeed if you have<\/p>\n<pre>Employee emp = new TeamLeader(new TeamMember(new EmployeeImpl()));<\/pre>\n<p>The emp doesn\u2019t have access to the TeamMember specific methods.<\/p>\n<p>This means that the pattern may not be a good choice for the situation.<\/p>\n<p>You can of course do<\/p>\n<pre>TeamMember member = new TeamMember(new EmployeeImpl());\n<em id=\"__mceDel\">TeamLeader leader = new TeamLeader(member);<\/em><\/pre>\n<p>and then access the specific methods from the right variable and the interface methods from either.&nbsp;<em id=\"__mceDel\">But I would say this is probably just not an appropriate use of this pattern.<\/em><\/p>\n<p>Stay Tuned for more of our Design Mantras in the later blogs ! Subscribe to Our Blogs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As&nbsp; explained in my&nbsp;previous Blog, &nbsp;if you are working with group of developers &nbsp;or individually implementing proper design concepts like the&nbsp;Singleton Design Pattern, you don\u2019t have to spend time explaining the intricacies of a your solution. &nbsp;If you are familiar with the Singleton pattern, you are much further along in the design process path. However, [&hellip;]<\/p>\n","protected":false},"author":192,"featured_media":15810,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[914,2037,1949],"tags":[3608,3609,3610],"class_list":["post-30100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud","category-news-more-india","category-tech-india","tag-decorator-design-pattern-india","tag-what-is-decorator-in-code-design-india","tag-what-is-decorator-pattern-india"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Simplifying Coding with the Decorator Design Pattern \u00e2\u20ac\u201c When To &amp; When Not to Use it! - Blazeclan<\/title>\n<meta name=\"description\" content=\"As explained in my previous Blog, if you are working with group of developers or individually implementing proper design concepts like the Singleton Design Pattern, you don\u00e2\u20ac\u2122t have to spend time explaining the intricacies of a your solution.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Simplifying Coding with the Decorator Design Pattern \u00e2\u20ac\u201c When To &amp; When Not to Use it! - Blazeclan\" \/>\n<meta property=\"og:description\" content=\"As explained in my previous Blog, if you are working with group of developers or individually implementing proper design concepts like the Singleton Design Pattern, you don\u00e2\u20ac\u2122t have to spend time explaining the intricacies of a your solution.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/\" \/>\n<meta property=\"og:site_name\" content=\"Blazeclan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/blazeclan.hq\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-25T12:51:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-06T09:55:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1650\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Team Blazeclan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@blazeclan_hq\" \/>\n<meta name=\"twitter:site\" content=\"@blazeclan_hq\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Team Blazeclan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/\"},\"author\":{\"name\":\"Team Blazeclan\",\"@id\":\"https:\/\/blazeclan.com\/india\/#\/schema\/person\/779910eccddff4a1ea6663b6bfb271e8\"},\"headline\":\"Simplifying Coding with the Decorator Design Pattern \u2013 When To &amp; When Not to Use it!\",\"datePublished\":\"2022-11-25T12:51:41+00:00\",\"dateModified\":\"2023-03-06T09:55:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/\"},\"wordCount\":972,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/blazeclan.com\/india\/#organization\"},\"image\":{\"@id\":\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png\",\"keywords\":[\"Decorator Design Pattern\",\"What is Decorator in Code Design\",\"What is Decorator Pattern\"],\"articleSection\":[\"Cloud\",\"News &amp; More\",\"Tech\"],\"inLanguage\":\"en-IN\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/\",\"url\":\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/\",\"name\":\"Simplifying Coding with the Decorator Design Pattern \u00e2\u20ac\u201c When To & When Not to Use it! - Blazeclan\",\"isPartOf\":{\"@id\":\"https:\/\/blazeclan.com\/india\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png\",\"datePublished\":\"2022-11-25T12:51:41+00:00\",\"dateModified\":\"2023-03-06T09:55:47+00:00\",\"description\":\"As explained in my previous Blog, if you are working with group of developers or individually implementing proper design concepts like the Singleton Design Pattern, you don\u00e2\u20ac\u2122t have to spend time explaining the intricacies of a your solution.\",\"breadcrumb\":{\"@id\":\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#breadcrumb\"},\"inLanguage\":\"en-IN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-IN\",\"@id\":\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#primaryimage\",\"url\":\"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png\",\"contentUrl\":\"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png\",\"width\":1650,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blazeclan.com\/india\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Simplifying Coding with the Decorator Design Pattern \u2013 When To &amp; When Not to Use it!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blazeclan.com\/india\/#website\",\"url\":\"https:\/\/blazeclan.com\/india\/\",\"name\":\"Blazeclan\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/blazeclan.com\/india\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blazeclan.com\/india\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-IN\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/blazeclan.com\/india\/#organization\",\"name\":\"Blazeclan\",\"url\":\"https:\/\/blazeclan.com\/india\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-IN\",\"@id\":\"https:\/\/blazeclan.com\/india\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blazeclan.com\/wp-content\/uploads\/2024\/10\/ITCI-Blazeclan_logo.svg\",\"contentUrl\":\"https:\/\/blazeclan.com\/wp-content\/uploads\/2024\/10\/ITCI-Blazeclan_logo.svg\",\"caption\":\"Blazeclan\"},\"image\":{\"@id\":\"https:\/\/blazeclan.com\/india\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/blazeclan.hq\/\",\"https:\/\/x.com\/blazeclan_hq\",\"https:\/\/www.instagram.com\/blazeclantechnologies\/\",\"https:\/\/www.linkedin.com\/company\/blazeclan-technologies\/\",\"https:\/\/www.youtube.com\/channel\/UCCKF4Lcbtus-pUoZr7Lxrow\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/blazeclan.com\/india\/#\/schema\/person\/779910eccddff4a1ea6663b6bfb271e8\",\"name\":\"Team Blazeclan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-IN\",\"@id\":\"https:\/\/blazeclan.com\/india\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a43c1fa01bb3c7e839254c9084bf11ed422d7e633231f9e935096045af416ba2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a43c1fa01bb3c7e839254c9084bf11ed422d7e633231f9e935096045af416ba2?s=96&d=mm&r=g\",\"caption\":\"Team Blazeclan\"},\"sameAs\":[\"http:\/\/localhost\/ps-local-wp\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Simplifying Coding with the Decorator Design Pattern \u00e2\u20ac\u201c When To & When Not to Use it! - Blazeclan","description":"As explained in my previous Blog, if you are working with group of developers or individually implementing proper design concepts like the Singleton Design Pattern, you don\u00e2\u20ac\u2122t have to spend time explaining the intricacies of a your solution.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/","og_locale":"en_US","og_type":"article","og_title":"Simplifying Coding with the Decorator Design Pattern \u00e2\u20ac\u201c When To & When Not to Use it! - Blazeclan","og_description":"As explained in my previous Blog, if you are working with group of developers or individually implementing proper design concepts like the Singleton Design Pattern, you don\u00e2\u20ac\u2122t have to spend time explaining the intricacies of a your solution.","og_url":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/","og_site_name":"Blazeclan","article_publisher":"https:\/\/www.facebook.com\/blazeclan.hq\/","article_published_time":"2022-11-25T12:51:41+00:00","article_modified_time":"2023-03-06T09:55:47+00:00","og_image":[{"width":1650,"height":680,"url":"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png","type":"image\/png"}],"author":"Team Blazeclan","twitter_card":"summary_large_image","twitter_creator":"@blazeclan_hq","twitter_site":"@blazeclan_hq","twitter_misc":{"Written by":"Team Blazeclan","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#article","isPartOf":{"@id":"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/"},"author":{"name":"Team Blazeclan","@id":"https:\/\/blazeclan.com\/india\/#\/schema\/person\/779910eccddff4a1ea6663b6bfb271e8"},"headline":"Simplifying Coding with the Decorator Design Pattern \u2013 When To &amp; When Not to Use it!","datePublished":"2022-11-25T12:51:41+00:00","dateModified":"2023-03-06T09:55:47+00:00","mainEntityOfPage":{"@id":"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/"},"wordCount":972,"commentCount":0,"publisher":{"@id":"https:\/\/blazeclan.com\/india\/#organization"},"image":{"@id":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#primaryimage"},"thumbnailUrl":"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png","keywords":["Decorator Design Pattern","What is Decorator in Code Design","What is Decorator Pattern"],"articleSection":["Cloud","News &amp; More","Tech"],"inLanguage":"en-IN","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blazeclan.com\/india\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/","url":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/","name":"Simplifying Coding with the Decorator Design Pattern \u00e2\u20ac\u201c When To & When Not to Use it! - Blazeclan","isPartOf":{"@id":"https:\/\/blazeclan.com\/india\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#primaryimage"},"image":{"@id":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#primaryimage"},"thumbnailUrl":"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png","datePublished":"2022-11-25T12:51:41+00:00","dateModified":"2023-03-06T09:55:47+00:00","description":"As explained in my previous Blog, if you are working with group of developers or individually implementing proper design concepts like the Singleton Design Pattern, you don\u00e2\u20ac\u2122t have to spend time explaining the intricacies of a your solution.","breadcrumb":{"@id":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#breadcrumb"},"inLanguage":"en-IN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/"]}]},{"@type":"ImageObject","inLanguage":"en-IN","@id":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#primaryimage","url":"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png","contentUrl":"https:\/\/blazeclan.com\/wp-content\/uploads\/2014\/02\/Simplifying-Coding-with-the-Decorator-Design-Pattern-1.png","width":1650,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/blazeclan.com\/blog\/simplifying-coding-decorator-design-pattern-when-to-use-when-not-to-use\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blazeclan.com\/india\/"},{"@type":"ListItem","position":2,"name":"Simplifying Coding with the Decorator Design Pattern \u2013 When To &amp; When Not to Use it!"}]},{"@type":"WebSite","@id":"https:\/\/blazeclan.com\/india\/#website","url":"https:\/\/blazeclan.com\/india\/","name":"Blazeclan","description":"","publisher":{"@id":"https:\/\/blazeclan.com\/india\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blazeclan.com\/india\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-IN"},{"@type":"Organization","@id":"https:\/\/blazeclan.com\/india\/#organization","name":"Blazeclan","url":"https:\/\/blazeclan.com\/india\/","logo":{"@type":"ImageObject","inLanguage":"en-IN","@id":"https:\/\/blazeclan.com\/india\/#\/schema\/logo\/image\/","url":"https:\/\/blazeclan.com\/wp-content\/uploads\/2024\/10\/ITCI-Blazeclan_logo.svg","contentUrl":"https:\/\/blazeclan.com\/wp-content\/uploads\/2024\/10\/ITCI-Blazeclan_logo.svg","caption":"Blazeclan"},"image":{"@id":"https:\/\/blazeclan.com\/india\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/blazeclan.hq\/","https:\/\/x.com\/blazeclan_hq","https:\/\/www.instagram.com\/blazeclantechnologies\/","https:\/\/www.linkedin.com\/company\/blazeclan-technologies\/","https:\/\/www.youtube.com\/channel\/UCCKF4Lcbtus-pUoZr7Lxrow"]},{"@type":"Person","@id":"https:\/\/blazeclan.com\/india\/#\/schema\/person\/779910eccddff4a1ea6663b6bfb271e8","name":"Team Blazeclan","image":{"@type":"ImageObject","inLanguage":"en-IN","@id":"https:\/\/blazeclan.com\/india\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a43c1fa01bb3c7e839254c9084bf11ed422d7e633231f9e935096045af416ba2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a43c1fa01bb3c7e839254c9084bf11ed422d7e633231f9e935096045af416ba2?s=96&d=mm&r=g","caption":"Team Blazeclan"},"sameAs":["http:\/\/localhost\/ps-local-wp"]}]}},"_links":{"self":[{"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/posts\/30100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/users\/192"}],"replies":[{"embeddable":true,"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/comments?post=30100"}],"version-history":[{"count":0,"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/posts\/30100\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/media\/15810"}],"wp:attachment":[{"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/media?parent=30100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/categories?post=30100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blazeclan.com\/india\/wp-json\/wp\/v2\/tags?post=30100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}