{"id":645,"date":"2021-06-01T23:04:56","date_gmt":"2021-06-01T21:04:56","guid":{"rendered":"https:\/\/wojciechsiwek.pl\/?p=645"},"modified":"2025-02-02T11:13:08","modified_gmt":"2025-02-02T10:13:08","slug":"wzorzec-projektowy-budowniczy","status":"publish","type":"post","link":"https:\/\/wojciechsiwek.pl\/en\/wzorzec-projektowy-budowniczy\/","title":{"rendered":"Builder design pattern"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Continuing the series of entries about design patterns, I decided to take a builder design pattern to the workshop. This pattern is a creative pattern that can significantly simplify the application code, make it more transparent, and at the same time make us get a very simple tool for developing our application. 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-6a8d0f63eabaa\" 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-6a8d0f63eabaa\" 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-projektowy-budowniczy\/#Kiedy_i_Dlaczego_wlasnie_budowniczy\" >When and why exactly the builder?<\/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-projektowy-budowniczy\/#Zbudujmy_budowniczego\" >Let's build a builder<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-projektowy-budowniczy\/#Postawmy_nad_budowniczym_kierownika\" >Let's put a manager on the builder<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-projektowy-budowniczy\/#Podsumowanie\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Kiedy_i_Dlaczego_wlasnie_budowniczy\"><\/span>When and why exactly the builder?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The builder pattern can be used when we need to implement in our application the creation of objects that are structurally very similar to each other, but have different implementations. In addition, this pattern allows you to create objects in a stepwise manner. It is best if we try to present the problem with a simple example of creating a bolt object. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The screw seems to be a very simple item, but the multitude of its types makes it not easy to create one class that would be able to easily describe many of its types. Let's take an example of the features that a screw can have:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>thread size<\/li><li>thread type<\/li><li>thread length<\/li><li>bolt length<\/li><li>head shape<\/li><li>coating<\/li><li>type of coating<\/li><li>strength class,<\/li><li>left or right-handedness,<\/li><li>thread pitch,<\/li><li>the material from which it is made,<\/li><li>etc.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If we wanted to create an example constructor of our screw, we would have a nice monster that could look like this.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\"> Sruba srubaPierwsza = new Sruba(6, &quot;metryczna&quot;, 20, &quot;walcowy z gniazdem sze\u015bciok\u0105tnym&quot;, &quot;ocynk&quot;, &quot;8.8&quot;, &quot;prawoskretna&quot;, &quot;normalny&quot;);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">One such constructor could get over and overwork with filling it, but what to do if we would like to use many screws that would only differ in length, eg M6x15, M6x20, M6x30. It would be best if someone or something would fill such a constructor for us.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Zbudujmy_budowniczego\"><\/span>Let's build a builder<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So let's create a builder class for our screw-class facilities.<\/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\">Bolt class<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class Sruba {\n    private double rozmiarGwintu;\n    private String typ;\n    private double dlugosc;\n    private String typLba;\n    private String pokrycie;\n    private String klasa;\n    private String skretnosc;\n    private String skok;\n\n   \/\/setters and getters\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<p class=\"wp-block-paragraph\">Bulider class<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class SrubaTyp1 {\n    Sruba sruba;\n\n    public SrubaTyp1(double rozmiar, double dlugosc){\n        sruba = new Sruba();\n        sruba.setRozmiarGwintu(rozmiar);\n        sruba.setTyp(&quot;metryczna&quot;);\n        sruba.setDlugosc(dlugosc);\n        sruba.setTypLba(&quot;walcowy z gniazdem sze\u015bciok\u0105tnym&quot;);\n        sruba.setPokrycie(&quot;ocynk&quot;);\n        sruba.setKlasa(&quot;8.8&quot;);\n        sruba.setSkretnosc(&quot;prawoskrestna&quot;);\n        sruba.setSkok(&quot;normalny&quot;);\n    }\n\n    public Sruba getSruba() {\n        return sruba;\n    }\n}<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Note that now to create multiple type 1 bolts, all you need to do is create a type 1 bolt builder object and a Bolt class object to which we will assign the result of the builder's work as in the example below:<\/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        SrubaTyp1 budowniczy1 = new SrubaTyp1(6,20);\n        Sruba sruba1 = budowniczy1.getSruba();\n\n        budowniczy1.setDlugoscSrubby(25); \/\/zmieniam tylko d\u0142ugo\u015b\u0107\n        Sruba sruba2 = budowniczy1.getSruba(); \/\/tworz\u0119 kolejn\u0105 \u015brub\u0119 o nowej dlugosci\n\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">See how elegant solution we have received. Instead of creating many long, hardly readable constructors, we created a class that creates objects of the Bolt class for us. Similarly to the SrubaTyp1 class, you can create subsequent SrubaTyp2, SrubaTyp3 classes, etc. To ensure consistency and correct creation of the Sruba class objects, let's create an interface that will have to be implemented in each builder class of the Sruba class. <\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic interface SrubaTypy {\n    public void setRozmiarSruby(double rozmiarSruby);\n\n    public void setTyp(String typ);\n\n    public void setDlugosc(double dlugosc);\n\n    public void setTypLba(String typLba);\n\n    public void setPokrycie(String pokrycie);\n\n    public void setKlasa(String klasa);\n\n    public void setSkretnosc(String skretnosc);\n\n    public void setSkok(String skok);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Having such an interface, I change the SrubaTyp1 class so that it implements the interface written above:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class SrubaTyp1 implements SrubaTypy {\n    Sruba sruba;\n\n    public SrubaTyp1(double rozmiar, double dlugosc) {\n        sruba = new Sruba();\n        setRozmiarSruby(rozmiar);\n        setTyp(&quot;metryczna&quot;);\n        setDlugosc(dlugosc);\n        setTypLba(&quot;walcowy z gniazdem sze\u015bciok\u0105tnym&quot;);\n        setPokrycie(&quot;ocynk&quot;);\n        setKlasa(&quot;8.8&quot;);\n        setSkretnosc(&quot;prawoskrestna&quot;);\n        setSkok(&quot;normalny&quot;);\n    }\n\n    public Sruba getSruba() {\n        return sruba;\n    }\n\n    @Override\n    public void setRozmiarSruby(double rozmiar) {\n        sruba.setRozmiarGwintu(rozmiar);\n    }\n\n    @Override\n    public void setTyp(String typ) {\n        sruba.setTyp(typ);\n    }\n\n    @Override\n    public void setDlugosc(double dlugosc) {\n        sruba.setDlugosc(dlugosc);\n    }\n\n    @Override\n    public void setTypLba(String typLba) {\n        sruba.setTypLba(typLba);\n    }\n\n    @Override\n    public void setPokrycie(String pokrycie) {\n        sruba.setPokrycie(&quot;ocynk&quot;);\n    }\n\n    @Override\n    public void setKlasa(String klasa) {\n        sruba.setKlasa(klasa);\n    }\n\n    @Override\n    public void setSkretnosc(String skretnosc) {\n        sruba.setSkretnosc(skretnosc);\n    }\n\n    @Override\n    public void setSkok(String skok) {\n        sruba.setSkok(skok);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Notice that now we have a situation where the constructor creates the Bolts object for us and automatically fills in all the fields. In addition, we have the ability to freely change the values of Bolt fields through setters in the builder class. In the present situation, it is the builder himself who oversees the process of creating the bolt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Postawmy_nad_budowniczym_kierownika\"><\/span>Let's put a manager on the builder<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A builder pattern often uses an additional manager class to oversee the steps and sequence of using builder class methods. This approach makes the code clearer and easier to operate with builders. Let's write down an example of a manager's code:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class Kierownik {\n\n    public void stworzSrubeTypuPierwszego(SrubaTypy budowniczySruby) {\n        budowniczySruby.setDlugosc(20);\n        budowniczySruby.setRozmiarSruby(6);\n        budowniczySruby.setTypLba(&quot;Sto\u017ckowy z gniazdem sze\u015bciok\u0105tnym&quot;);\n    }\n\n    public void stworzSrubeTypuDrugiego(SrubaTypy budowniczySruby) {\n        budowniczySruby.setDlugosc(30);\n        budowniczySruby.setKlasa(&quot;8.8&quot;);\n        budowniczySruby.setRozmiarSruby(8);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Having a manager who instructs how to create an object of the bolt class, you can slim down the builder builder and then the class will look like this:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-java\" data-line=\"\">package com.company;\n\npublic class SrubaTyp1 implements SrubaTypy {\n    Sruba sruba;\n\n    public SrubaTyp1(double rozmiar, double dlugosc) {\n        sruba = new Sruba();\n    }\n\n    public Sruba getSruba() {\n        return sruba;\n    }\n\n    @Override\n    public void setRozmiarSruby(double rozmiar) {\n        sruba.setRozmiarGwintu(rozmiar);\n    }\n\n    @Override\n    public void setTyp(String typ) {\n        sruba.setTyp(typ);\n    }\n\n    @Override\n    public void setDlugosc(double dlugosc) {\n        sruba.setDlugosc(dlugosc);\n    }\n\n    @Override\n    public void setTypLba(String typLba) {\n        sruba.setTypLba(typLba);\n    }\n\n    @Override\n    public void setPokrycie(String pokrycie) {\n        sruba.setPokrycie(&quot;ocynk&quot;);\n    }\n\n    @Override\n    public void setKlasa(String klasa) {\n        sruba.setKlasa(klasa);\n    }\n\n    @Override\n    public void setSkretnosc(String skretnosc) {\n        sruba.setSkretnosc(skretnosc);\n    }\n\n    @Override\n    public void setSkok(String skok) {\n        sruba.setSkok(skok);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We gained a lighter builder class constructor, and also separated the bolt creation methodology into a separate class, which gave us clarity and ease in building subsequent implementations of different types of bolt in one place by adding new methods in the manager class. In addition, at this point, we have enabled the user to implement his own order of building the object, and in addition, we can now introduce, for example, conditional instructions in the manager's class, which will supervise the subsequent stages of creating the bolt object.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To use this class structure, let's rebuild our client code:<\/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        Kierownik kierownik = new Kierownik(); \/\/ zatrudniam do pracy kierownika\n        SrubaTypy budowniczySrubyPierwszy = new SrubaTyp1(); \/\/ zatrudniam pierwszego budowniczego\n        SrubaTypy budowniczySrubyDrugi = new SrubaTyp1(); \/\/ zatrudniam drugiego budowniczego\n\n        kierownik.stworzSrubeTypuPierwszego(budowniczySrubyPierwszy); \/\/przypisuj\u0119 do stowrzenia sruby konkretnego budowniczego\n        kierownik.stworzSrubeTypuDrugiego(budowniczySrubyDrugi); \/\/przypisuj\u0119 do stowrzenia sruby konkretnego budowniczego\n\n        Sruba pierwszaSruba = budowniczySrubyPierwszy.getSruba(); \/\/ przypisuje do pierwszaSruba efekt pracy budowniczego pierwszego\n        Sruba drugaSruba = budowniczySrubyDrugi.getSruba(); \/\/ przypisuje do drugaSruba efekt pracy budowniczego drugiego\n\n        System.out.println(&quot;---SRUBA PIERWSZA---&quot;);\n        System.out.println(&quot;Rozmiar gwintu: &quot; + pierwszaSruba.getRozmiarGwintu());\n        System.out.println(&quot;Typ: &quot; + pierwszaSruba.getTyp());\n        System.out.println(&quot;Dlugosc: &quot; + pierwszaSruba.getDlugosc());\n        System.out.println(&quot;Typ Lba: &quot; + pierwszaSruba.getTypLba());\n        System.out.println(&quot;Pokrycie: &quot; + pierwszaSruba.getPokrycie());\n        System.out.println(&quot;Klasa: &quot; + pierwszaSruba.getKlasa());\n        System.out.println(&quot;Skretnosc: &quot; + pierwszaSruba.getSkretnosc());\n        System.out.println(&quot;Skok: &quot; + pierwszaSruba.getSkok());\n\n        System.out.println(&quot;---SRUBA DRUGA---&quot;);\n        System.out.println(&quot;Rozmiar gwintu: &quot; + drugaSruba.getRozmiarGwintu());\n        System.out.println(&quot;Typ: &quot; + drugaSruba.getTyp());\n        System.out.println(&quot;Dlugosc: &quot; + drugaSruba.getDlugosc());\n        System.out.println(&quot;Typ Lba: &quot; + drugaSruba.getTypLba());\n        System.out.println(&quot;Pokrycie: &quot; + drugaSruba.getPokrycie());\n        System.out.println(&quot;Klasa: &quot; + drugaSruba.getKlasa());\n        System.out.println(&quot;Skretnosc: &quot; + drugaSruba.getSkretnosc());\n        System.out.println(&quot;Skok: &quot; + drugaSruba.getSkok());\n\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The result of starting the program will be as follows:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"\" data-line=\"\">---SRUBA PIERWSZA---\nRozmiar gwintu: 6.0\nTyp: null\nDlugosc: 20.0\nTyp Lba: Sto\u017ckowy z gniazdem sze\u015bciok\u0105tnym\nPokrycie: null\nKlasa: null\nSkretnosc: null\nSkok: null\n---SRUBA DRUGA---\nRozmiar gwintu: 8.0\nTyp: null\nDlugosc: 30.0\nTyp Lba: null\nPokrycie: null\nKlasa: 8.8\nSkretnosc: null\nSkok: null\n\nProcess finished with exit code 0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Podsumowanie\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Builder Pattern is a moderately complex design pattern, but when used wisely, it adds flexibility to the application and allows the developer to create objects in stages. In addition, the client code is significantly simplified and more transparent, which results, for example, from the lack of the need to create complex and extensive constructors.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The main disadvantage of this pattern is that it requires the creation of additional classes and interfaces, which in some projects may unnecessarily complicate its class structure. <\/p>","protected":false},"excerpt":{"rendered":"<p>Kontynuuj\u0105c seri\u0119 wpis\u00f3w o wzorcach projektowych postanowi\u0142em wzi\u0105\u0107 na warsztat wzorzec projektowy budowniczy. Wzorzec ten jest wzorcem kreacyjnym, kt\u00f3ry potrafi znacz\u0105co upro\u015bci\u0107 kod aplikacji, uczyni\u0107 go bardziej przejrzystym, a jednocze\u015bnie sprawi\u0107, \u017ce dostajemy bardzo proste narz\u0119dzie do rozbudowy naszej aplikacji. Zapraszam do lektury. Kiedy i Dlaczego w\u0142a\u015bnie budowniczy? Wzorzec budowniczy mo\u017cna u\u017cy\u0107 w\u00f3wczas, gdy musimy&hellip;&nbsp;<a href=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-projektowy-budowniczy\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Builder 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-645","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 projektowy budowniczy &#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-projektowy-budowniczy\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wzorzec projektowy budowniczy &#8211; Wojciech Siwek\" \/>\n<meta property=\"og:description\" content=\"Kontynuuj\u0105c seri\u0119 wpis\u00f3w o wzorcach projektowych postanowi\u0142em wzi\u0105\u0107 na warsztat wzorzec projektowy budowniczy. Wzorzec ten jest wzorcem kreacyjnym, kt\u00f3ry potrafi znacz\u0105co upro\u015bci\u0107 kod aplikacji, uczyni\u0107 go bardziej przejrzystym, a jednocze\u015bnie sprawi\u0107, \u017ce dostajemy bardzo proste narz\u0119dzie do rozbudowy naszej aplikacji. Zapraszam do lektury. Kiedy i Dlaczego w\u0142a\u015bnie budowniczy? Wzorzec budowniczy mo\u017cna u\u017cy\u0107 w\u00f3wczas, gdy musimy&hellip;&nbsp;Read More &raquo;Wzorzec projektowy budowniczy\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wojciechsiwek.pl\/en\/wzorzec-projektowy-budowniczy\/\" \/>\n<meta property=\"og:site_name\" content=\"Wojciech Siwek\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-01T21:04:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-02T10:13:08+00:00\" \/>\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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-projektowy-budowniczy\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-projektowy-budowniczy\\\/\"},\"author\":{\"name\":\"Wojciech Siwek\",\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#\\\/schema\\\/person\\\/eb4246ee83fb20ed02fc723e28258677\"},\"headline\":\"Wzorzec projektowy budowniczy\",\"datePublished\":\"2021-06-01T21:04:56+00:00\",\"dateModified\":\"2025-02-02T10:13:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-projektowy-budowniczy\\\/\"},\"wordCount\":723,\"publisher\":{\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#\\\/schema\\\/person\\\/eb4246ee83fb20ed02fc723e28258677\"},\"keywords\":[\"java\",\"programowanie\",\"wzorce projektowe\"],\"articleSection\":[\"Programowanie\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-projektowy-budowniczy\\\/\",\"url\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-projektowy-budowniczy\\\/\",\"name\":\"Wzorzec projektowy budowniczy &#8211; Wojciech Siwek\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/wojciechsiwek.pl\\\/#website\"},\"datePublished\":\"2021-06-01T21:04:56+00:00\",\"dateModified\":\"2025-02-02T10:13:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-projektowy-budowniczy\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-projektowy-budowniczy\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wojciechsiwek.pl\\\/wzorzec-projektowy-budowniczy\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Strona g\u0142\u00f3wna\",\"item\":\"https:\\\/\\\/wojciechsiwek.pl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Wzorzec projektowy budowniczy\"}]},{\"@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 projektowy budowniczy &#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-projektowy-budowniczy\/","og_locale":"en_GB","og_type":"article","og_title":"Wzorzec projektowy budowniczy &#8211; Wojciech Siwek","og_description":"Kontynuuj\u0105c seri\u0119 wpis\u00f3w o wzorcach projektowych postanowi\u0142em wzi\u0105\u0107 na warsztat wzorzec projektowy budowniczy. Wzorzec ten jest wzorcem kreacyjnym, kt\u00f3ry potrafi znacz\u0105co upro\u015bci\u0107 kod aplikacji, uczyni\u0107 go bardziej przejrzystym, a jednocze\u015bnie sprawi\u0107, \u017ce dostajemy bardzo proste narz\u0119dzie do rozbudowy naszej aplikacji. Zapraszam do lektury. Kiedy i Dlaczego w\u0142a\u015bnie budowniczy? Wzorzec budowniczy mo\u017cna u\u017cy\u0107 w\u00f3wczas, gdy musimy&hellip;&nbsp;Read More &raquo;Wzorzec projektowy budowniczy","og_url":"https:\/\/wojciechsiwek.pl\/en\/wzorzec-projektowy-budowniczy\/","og_site_name":"Wojciech Siwek","article_published_time":"2021-06-01T21:04:56+00:00","article_modified_time":"2025-02-02T10:13:08+00:00","author":"Wojciech Siwek","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Wojciech Siwek","Estimated reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wojciechsiwek.pl\/wzorzec-projektowy-budowniczy\/#article","isPartOf":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-projektowy-budowniczy\/"},"author":{"name":"Wojciech Siwek","@id":"http:\/\/wojciechsiwek.pl\/#\/schema\/person\/eb4246ee83fb20ed02fc723e28258677"},"headline":"Wzorzec projektowy budowniczy","datePublished":"2021-06-01T21:04:56+00:00","dateModified":"2025-02-02T10:13:08+00:00","mainEntityOfPage":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-projektowy-budowniczy\/"},"wordCount":723,"publisher":{"@id":"http:\/\/wojciechsiwek.pl\/#\/schema\/person\/eb4246ee83fb20ed02fc723e28258677"},"keywords":["java","programowanie","wzorce projektowe"],"articleSection":["Programowanie"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/wojciechsiwek.pl\/wzorzec-projektowy-budowniczy\/","url":"https:\/\/wojciechsiwek.pl\/wzorzec-projektowy-budowniczy\/","name":"Wzorzec projektowy budowniczy &#8211; Wojciech Siwek","isPartOf":{"@id":"http:\/\/wojciechsiwek.pl\/#website"},"datePublished":"2021-06-01T21:04:56+00:00","dateModified":"2025-02-02T10:13:08+00:00","breadcrumb":{"@id":"https:\/\/wojciechsiwek.pl\/wzorzec-projektowy-budowniczy\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wojciechsiwek.pl\/wzorzec-projektowy-budowniczy\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wojciechsiwek.pl\/wzorzec-projektowy-budowniczy\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Strona g\u0142\u00f3wna","item":"https:\/\/wojciechsiwek.pl\/"},{"@type":"ListItem","position":2,"name":"Wzorzec projektowy budowniczy"}]},{"@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\/645","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=645"}],"version-history":[{"count":13,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/posts\/645\/revisions"}],"predecessor-version":[{"id":685,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/posts\/645\/revisions\/685"}],"wp:attachment":[{"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/media?parent=645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/categories?post=645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wojciechsiwek.pl\/en\/wp-json\/wp\/v2\/tags?post=645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}