{"id":608,"date":"2021-05-18T21:32:33","date_gmt":"2021-05-18T19:32:33","guid":{"rendered":"https:\/\/wojciechsiwek.pl\/?p=608"},"modified":"2025-02-02T11:13:08","modified_gmt":"2025-02-02T10:13:08","slug":"wzorzec-dekorator","status":"publish","type":"post","link":"https:\/\/wojciechsiwek.pl\/en\/wzorzec-dekorator\/","title":{"rendered":"Decorator design pattern"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Another design pattern that I will describe will be the title decorator. This pattern can be easily imagined as an implementation of the work of an interior decorator who, getting an unfinished apartment, decorates it with various gadgets. As a result, we get the same apartment, but it is already modified. What does it look like in programming? I invite you to read.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Spis Tre\u015bci<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a8d10eff294c\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a8d10eff294c\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-dekorator\/#Przedstawmy_problem\" >Let's present the problem<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-dekorator\/#Rozwiazmy_problem\" >Let's solve the problem<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Przedstawmy_problem\"><\/span>Let's present the problem<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The decorator pattern assumes the existence of two kinds of classes, which we will colloquially call the decorated and decorating class. In the example of an interior decorator, the class will decorate the apartment, and the class will decorate the ornament, or the decorative element that decorates the apartment. Every action performed by the decorator in the apartment causes that the apartment is still an apartment, but gains new functionalities.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At this point, one could directly think that inheritance is ideally suited to this mechanism. The problem is that each decorator has a palette of beaten paths and elements to use in his work. After all, why reinvent the wheel for each project? Creating the final project each time would require the decorator to write many classes, each of which would add one effect to the apartment, which, with many projects carried out by him, would multiply a lot of classes that would be difficult to reuse. Let's see an example below:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph\">flat 1<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">class Mieszkanie {\n    int iloscScian = 4;\n}\n\nclass MieszkanieJasne\nextends Mieszkanie{\n    String kolor = &quot;bia\u0142y&quot;;\n}\n\nclass MieszkanieBialeDuze\nextends MieszkanieBiale{\n    double powierzchniaM2 = 120;\n}\n\nclass MieszkanieBialeDuzeZBalkonem\nextends MieszkanieBialeDuze{\n    boolean balkon = true;\n}<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"wp-block-paragraph\">flat 2<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">class Mieszkanie {\n    int iloscScian = 4;\n}\n\nclass MieszkanieCiemne \nextends Mieszkanie{\n    String kolor = &quot;czarny&quot;;\n}\n\nclass MieszkanieCiemneMale\nextends MieszkanieCiemne{\n    double powierzchniaM2 = 42;\n}\n\nclass MieszkanieCiemneMaleZTarasem\nextends MieszkanieCiemneMale{\n    boolean taras = true;\n}\n<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Note that if we only wanted to create a small bright apartment with a terrace, we can only use the MieszkanieJasne class, while the remaining 2 should be added. This is not a convenient solution. Additionally, there is a problem when we want to compare two objects with each other. Note that both of them are of different types, so they cannot be compared to each other.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Rozwiazmy_problem\"><\/span>Let's solve the problem<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An ideal solution for an interior decorator would be if he could compose each apartment from ready-made components, and then, for his own understanding, assess the attractiveness of the solution based on a parameter. This is where the decorator pattern triumphantly comes in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At the very beginning, let's look at the final piece of code on which an interior decorator works to create new compositions.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">Mieszkanie piekneMieszkanie = new MieszkanieNowe(); \/\/tworzymy nasze pi\u0119kne mieszkanie\npiekneMieszkanie = new Jasne(piekneMieszkanie); \/\/dekorujemy mieszkanie jasnymi \u015bcianami\npiekneMieszkanie = new ZTarasem(piekneMieszkanie); \/\/dodajemy aran\u017cacj\u0119 tarasu<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Note that we are constantly working on our originally created object and wrapping it with new new objects. We do not change the type of object because we are still using the Apartment class. Both the object decorated with a beautiful Apartment and the decorating objects are of the same type, which may seem not very intuitive, but they offer great possibilities. The saved solution can be represented graphically as follows:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-1024x629.png\" alt=\"\" class=\"wp-image-629\" width=\"515\" height=\"316\" srcset=\"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-1024x629.png 1024w, https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-300x184.png 300w, https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-768x472.png 768w, https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-1536x944.png 1536w, https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-2048x1259.png 2048w\" sizes=\"auto, (max-width: 515px) 100vw, 515px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">For type compatibility, all classes extend the base abstract class Apartment:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic abstract class Mieszkanie {\n    String opis; \/\/zawiera opis dodawanej funkcjonalnosci\n\n    public String getOpis() {\n        return opis;\n    }\n\n    public abstract int indeksWartosci(); \/\/zwraca wartosc wspolczynnika atrakcyjnosci mieszkania\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On this basis, we create our decorated class New Apartment (later you can create similarly other classes, such as Single-family House, Seregowiec, etc.):<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class MieszkanieNowe extends Mieszkanie { \/\/rozszerzamy klase Mieszkanie\n\n    public MieszkanieNowe() {\n        opis = &quot;Mieszkanie z rynku pierwotnego&quot;;\n    }\n\n    @Override\n    public int indeksWartosci() {\n        return 50;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this way, we created a decorated class which is the starting point of the entire composition. Now we'll move on to creating decorators, and we'll start with the fact that, as previously mentioned, the decorating class must be of the same type as the decorating class. So let's create a class:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic abstract class Ozdoba extends Mieszkanie{\n    public abstract String getOpis();\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We will use this class to create appropriate decorating classes, such as:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class Jasne extends Ozdoba {\n    Mieszkanie mieszkanie;\n\n    public Jasne(Mieszkanie mieszkanie) {\n        this.mieszkanie = mieszkanie;\n    }\n\n    @Override\n    public int indeksWartosci() {\n        return mieszkanie.indeksWartosci() + 4;\n    }\n\n    @Override\n    public String getOpis() {\n        return mieszkanie.getOpis() + &quot; + Sciany jasne&quot;;\n    }\n}\n<\/code><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class ZTarasem extends Ozdoba {\n    Mieszkanie mieszkanie;\n\n    public ZTarasem(Mieszkanie mieszkanie) {\n        this.mieszkanie = mieszkanie;\n    }\n\n    @Override\n    public int indeksWartosci() {\n        return mieszkanie.indeksWartosci() + 10;\n    }\n\n    @Override\n    public String getOpis() {\n        return mieszkanie.getOpis() + &quot; + Taras&quot;;\n    }\n}\n<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Note that in the constructor of both classes I pass the existing apartment object already decorated in some way and in the methods indexWartosci () and getOpis () I add new data to the previous object.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We just created a simple application implementing the decorator pattern. Finally, let's see how our application will work after putting together all the classes in main:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class Main {\n\n    public static void main(String[] args) {\n        Mieszkanie piekneMieszkanie = new MieszkanieNowe(); \/\/tworzymy nasze pi\u0119kne mieszkanie\n        piekneMieszkanie = new Jasne(piekneMieszkanie); \/\/dekorujemy mieszkanie jasnymi \u015bcianami\n        piekneMieszkanie = new ZTarasem(piekneMieszkanie); \/\/dodajemy aran\u017cacj\u0119 tarasu\n\n        System.out.println(&quot;Indeks warto\u015bci:  &quot; + piekneMieszkanie.indeksWartosci() + &quot;, zawiera:  &quot; + piekneMieszkanie.getOpis());\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The program output looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"\" data-line=\"\">Indeks warto\u015bci:  64, zawiera:  Mieszkanie z rynku pierwotnego + Sciany jasne + Taras\n\nProcess finished with exit code 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Note that now it is very easy to add new classes, both decorated and decorated, because each time we can safely use previously written classes without worrying about their mutual compatibility.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, I will present the definition of the decorator pattern, which should be more understandable to you after reading this article:<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p><strong>Decorator design pattern <\/strong>allows you to dynamically assign new behaviors to a given object. Decorators provide flexibility similar to inheritance, but offer significantly expanded functionality in return.<\/p><\/blockquote><\/figure>\n\n\n\n<p class=\"wp-block-paragraph translation-block\">In the above definition, it is also worth paying attention to the word <strong> dynamic <\/strong>, because nothing prevents our interior decorator from implementing a solution based on artificial intelligence in the future. It would collect information about the owner of the apartment and on this basis, while the program is running, it would simulate how the apartment could be arranged for the client.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I hope that my article convinced you and gave you understanding about the decorator pattern, and if you have any comments, feel free to comment or contact us via the form.<\/p>","protected":false},"excerpt":{"rendered":"<p>Kolejnym wzorcem projektowym, kt\u00f3ry opisz\u0119 b\u0119dzie tytu\u0142owy dekorator. Wzorzec ten \u0142atwo mo\u017cna sobie wyobrazi\u0107 jako implementacj\u0119 pracy dekoratora wn\u0119trz, kt\u00f3ry dostaj\u0105c mieszkanie nieurz\u0105dzone zajmuje si\u0119 przyozdabianiem go w r\u00f3\u017cne gad\u017cety. W efekcie dostajemy to samo mieszkanie jednak jest ono ju\u017c zmodyfikowane. Jak to wygl\u0105da w programowaniu? Zapraszam do lektury. Przedstawmy problem Wzorzec dekorator zak\u0142ada istnienie&hellip;&nbsp;<a href=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-dekorator\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Decorator design pattern<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[26],"tags":[25,23,22],"class_list":["post-608","post","type-post","status-publish","format-standard","hentry","category-programowanie","tag-java","tag-programowanie","tag-wzorce-projektowe"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Wzorzec Dekorator &#8211; Wojciech Siwek<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-dekorator\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wzorzec Dekorator &#8211; Wojciech Siwek\" \/>\n<meta property=\"og:description\" content=\"Kolejnym wzorcem projektowym, kt\u00f3ry opisz\u0119 b\u0119dzie tytu\u0142owy dekorator. Wzorzec ten \u0142atwo mo\u017cna sobie wyobrazi\u0107 jako implementacj\u0119 pracy dekoratora wn\u0119trz, kt\u00f3ry dostaj\u0105c mieszkanie nieurz\u0105dzone zajmuje si\u0119 przyozdabianiem go w r\u00f3\u017cne gad\u017cety. W efekcie dostajemy to samo mieszkanie jednak jest ono ju\u017c zmodyfikowane. Jak to wygl\u0105da w programowaniu? Zapraszam do lektury. Przedstawmy problem Wzorzec dekorator zak\u0142ada istnienie&hellip;&nbsp;Read More &raquo;Wzorzec Dekorator\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-dekorator\/\" \/>\n<meta property=\"og:site_name\" content=\"Wojciech Siwek\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-18T19:32:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-02T10:13:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator.png\" \/>\n\t<meta property=\"og:image:width\" content=\"3018\" \/>\n\t<meta property=\"og:image:height\" content=\"1855\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Wojciech Siwek\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Wojciech Siwek\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/\"},\"author\":{\"name\":\"Wojciech Siwek\",\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#\\\/schema\\\/person\\\/eb4246ee83fb20ed02fc723e28258677\"},\"headline\":\"Wzorzec Dekorator\",\"datePublished\":\"2021-05-18T19:32:33+00:00\",\"dateModified\":\"2025-02-02T10:13:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/\"},\"wordCount\":797,\"publisher\":{\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#\\\/schema\\\/person\\\/eb4246ee83fb20ed02fc723e28258677\"},\"image\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/dekorator-1024x629.png\",\"keywords\":[\"java\",\"programowanie\",\"wzorce projektowe\"],\"articleSection\":[\"Programowanie\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/\",\"url\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/\",\"name\":\"Wzorzec Dekorator &#8211; Wojciech Siwek\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/dekorator-1024x629.png\",\"datePublished\":\"2021-05-18T19:32:33+00:00\",\"dateModified\":\"2025-02-02T10:13:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/#primaryimage\",\"url\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/dekorator-1024x629.png\",\"contentUrl\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/dekorator-1024x629.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-dekorator\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Strona g\u0142\u00f3wna\",\"item\":\"https:\\\/\\\/wojciechsiwek.pl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Wzorzec Dekorator\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#website\",\"url\":\"http:\\\/\\\/wojciechsiwek.pl\\\/\",\"name\":\"Wojciech Siwek\",\"description\":\"Programista na pocz\u0105tku swojej \u015bcie\u017cki w IT\",\"publisher\":{\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#\\\/schema\\\/person\\\/eb4246ee83fb20ed02fc723e28258677\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/wojciechsiwek.pl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#\\\/schema\\\/person\\\/eb4246ee83fb20ed02fc723e28258677\",\"name\":\"Wojciech Siwek\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/cropped-logo.png\",\"url\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/cropped-logo.png\",\"contentUrl\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/cropped-logo.png\",\"width\":313,\"height\":306,\"caption\":\"Wojciech Siwek\"},\"logo\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wp-content\\\/uploads\\\/2021\\\/03\\\/cropped-logo.png\"},\"sameAs\":[\"https:\\\/\\\/wojciechsiwek.pl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Wzorzec Dekorator &#8211; Wojciech Siwek","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:\/\/wojciechsiwek.pl\/en\/wzorzec-dekorator\/","og_locale":"en_GB","og_type":"article","og_title":"Wzorzec Dekorator &#8211; Wojciech Siwek","og_description":"Kolejnym wzorcem projektowym, kt\u00f3ry opisz\u0119 b\u0119dzie tytu\u0142owy dekorator. Wzorzec ten \u0142atwo mo\u017cna sobie wyobrazi\u0107 jako implementacj\u0119 pracy dekoratora wn\u0119trz, kt\u00f3ry dostaj\u0105c mieszkanie nieurz\u0105dzone zajmuje si\u0119 przyozdabianiem go w r\u00f3\u017cne gad\u017cety. W efekcie dostajemy to samo mieszkanie jednak jest ono ju\u017c zmodyfikowane. Jak to wygl\u0105da w programowaniu? Zapraszam do lektury. Przedstawmy problem Wzorzec dekorator zak\u0142ada istnienie&hellip;&nbsp;Read More &raquo;Wzorzec Dekorator","og_url":"https:\/\/wojciechsiwek.pl\/en\/wzorzec-dekorator\/","og_site_name":"Wojciech Siwek","article_published_time":"2021-05-18T19:32:33+00:00","article_modified_time":"2025-02-02T10:13:08+00:00","og_image":[{"width":3018,"height":1855,"url":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator.png","type":"image\/png"}],"author":"Wojciech Siwek","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Wojciech Siwek","Estimated reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/#article","isPartOf":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/"},"author":{"name":"Wojciech Siwek","@id":"http:\/\/wojciechsiwek.pl\/#\/schema\/person\/eb4246ee83fb20ed02fc723e28258677"},"headline":"Wzorzec Dekorator","datePublished":"2021-05-18T19:32:33+00:00","dateModified":"2025-02-02T10:13:08+00:00","mainEntityOfPage":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/"},"wordCount":797,"publisher":{"@id":"http:\/\/wojciechsiwek.pl\/#\/schema\/person\/eb4246ee83fb20ed02fc723e28258677"},"image":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/#primaryimage"},"thumbnailUrl":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-1024x629.png","keywords":["java","programowanie","wzorce projektowe"],"articleSection":["Programowanie"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/","url":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/","name":"Wzorzec Dekorator &#8211; Wojciech Siwek","isPartOf":{"@id":"http:\/\/wojciechsiwek.pl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/#primaryimage"},"image":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/#primaryimage"},"thumbnailUrl":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-1024x629.png","datePublished":"2021-05-18T19:32:33+00:00","dateModified":"2025-02-02T10:13:08+00:00","breadcrumb":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/#primaryimage","url":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-1024x629.png","contentUrl":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/05\/dekorator-1024x629.png"},{"@type":"BreadcrumbList","@id":"https:\/\/wojciechsiwek.pl\/wzorzec-dekorator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Strona g\u0142\u00f3wna","item":"https:\/\/wojciechsiwek.pl\/"},{"@type":"ListItem","position":2,"name":"Wzorzec Dekorator"}]},{"@type":"WebSite","@id":"http:\/\/wojciechsiwek.pl\/#website","url":"http:\/\/wojciechsiwek.pl\/","name":"Wojciech Siwek","description":"Software developer at the beginning of his career in IT","publisher":{"@id":"http:\/\/wojciechsiwek.pl\/#\/schema\/person\/eb4246ee83fb20ed02fc723e28258677"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/wojciechsiwek.pl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"http:\/\/wojciechsiwek.pl\/#\/schema\/person\/eb4246ee83fb20ed02fc723e28258677","name":"Wojciech Siwek","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/03\/cropped-logo.png","url":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/03\/cropped-logo.png","contentUrl":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/03\/cropped-logo.png","width":313,"height":306,"caption":"Wojciech Siwek"},"logo":{"@id":"https:\/\/wojciechsiwek.pl\/wp-content\/uploads\/2021\/03\/cropped-logo.png"},"sameAs":["https:\/\/wojciechsiwek.pl"]}]}},"_links":{"self":[{"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/posts\/608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/comments?post=608"}],"version-history":[{"count":32,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/posts\/608\/revisions"}],"predecessor-version":[{"id":641,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/posts\/608\/revisions\/641"}],"wp:attachment":[{"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/media?parent=608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/categories?post=608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/tags?post=608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}