{"id":907,"date":"2020-08-18T11:11:00","date_gmt":"2020-08-18T11:11:00","guid":{"rendered":"https:\/\/www.juniorjavadeveloper.pl\/?p=907"},"modified":"2023-11-19T17:31:08","modified_gmt":"2023-11-19T17:31:08","slug":"pulapki-szablonu-crud-z-bootcamp-we-wlasnym-portfolio-i-rzeczywistym-projekcie","status":"publish","type":"post","link":"https:\/\/www.juniorjavadeveloper.pl\/en\/2020\/08\/18\/pulapki-szablonu-crud-z-bootcamp-we-wlasnym-portfolio-i-rzeczywistym-projekcie\/","title":{"rendered":"Pitfalls of the CRUD template in your own portfolio and real project"},"content":{"rendered":"<p class=\"has-large-font-size wp-block-paragraph\">In this article, I will describe the pitfalls and dangers of the Spring Boot CRUD template taught at Bootcamp. Let me make it clear that I am not against bootcamps. I simply know from my own experience what my students who have learned or not learned at Bootcamp how to create CRUD applications using Springframework are struggling with. Yes, many people at various stages of Bootcamp contact me.<\/p>\n\n\n    <style>\r\n        .wpj-jtoc.--jtoc-theme-basic-light.--jtoc-has-custom-styles {\r\n            --jtoc-numeration-suffix: \". \";\n--jtoc-numeration-color: #adadad;\n        }\r\n\r\n            <\/style>\r\n\r\n\r\n\r\n<div id=\"wpj-jtoc\" class=\"wpj-jtoc wpj-jtoc--main --jtoc-the-content --jtoc-theme-basic-light --jtoc-title-align-left --jtoc-toggle-icon --jtoc-toggle-position-right --jtoc-toggle-1 --jtoc-has-numeration --jtoc-has-custom-styles --jtoc-is-unfolded\" >\r\n\r\n    \r\n    <!-- TOC -->\r\n    <div class=\"wpj-jtoc--toc\">\r\n                                <div class=\"wpj-jtoc--header\">\r\n                <div class=\"wpj-jtoc--header-main\">\r\n                                        <div class=\"wpj-jtoc--title\">\r\n                        <span class=\"wpj-jtoc--title-label\">Table of Contents<\/span>\r\n                    <\/div>\r\n                                                                <div class=\"wpj-jtoc--toggle-wrap\">\r\n                                                                                                                    <div class=\"wpj-jtoc--toggle-box\">\r\n                                    <div class=\"wpj-jtoc--toggle\"><\/div>\r\n                                <\/div>\r\n                                                    <\/div>\r\n                                    <\/div>\r\n            <\/div>\r\n                            <div class=\"wpj-jtoc--body\">\r\n                        <nav class=\"wpj-jtoc--nav\">\r\n                <ol class=\"wpj-jtoc--items\"><li class=\"wpj-jtoc--item --jtoc-h2\">\r\n        <div class=\"wpj-jtoc--item-content\" data-depth=\"2\">\r\n                <a href=\"#wstep\" title=\"Preface\" data-numeration=\"1\">Preface<\/a>\r\n                    <\/div> <\/li><li class=\"wpj-jtoc--item --jtoc-h2\">\r\n        <div class=\"wpj-jtoc--item-content\" data-depth=\"2\">\r\n                <a href=\"#powtarzalnosc-i-powszechnosc-rozwiazan-powielanych-w-projektach\" title=\"Repeatability and universality of solutions replicated in projects\" data-numeration=\"2\">Repeatability and universality of solutions replicated in projects<\/a>\r\n                    <\/div> <ol class=\"wpj-jtoc--items\"><li class=\"wpj-jtoc--item --jtoc-h3\">\r\n        <div class=\"wpj-jtoc--item-content\" data-depth=\"3\">\r\n                <a href=\"#jak-rozwiazac-problem\" title=\"How to solve the problem?\" data-numeration=\"2.1\">How to solve the problem?<\/a>\r\n                    <\/div> <\/li><\/ol><\/li><li class=\"wpj-jtoc--item --jtoc-h2\">\r\n        <div class=\"wpj-jtoc--item-content\" data-depth=\"2\">\r\n                <a href=\"#schematyczne-i-wierne-odzwierciedlanie-wyuczonego-szablonu\" title=\"Schematic and literal reflection of the learned template\" data-numeration=\"3\">Schematic and literal reflection of the learned template<\/a>\r\n                    <\/div> <ol class=\"wpj-jtoc--items\"><li class=\"wpj-jtoc--item --jtoc-h3\">\r\n        <div class=\"wpj-jtoc--item-content\" data-depth=\"3\">\r\n                <a href=\"#jak-rozwiazac-problem_1\" title=\"How to solve the problem?\" data-numeration=\"3.1\">How to solve the problem?<\/a>\r\n                    <\/div> <\/li><\/ol><\/li><li class=\"wpj-jtoc--item --jtoc-h2\">\r\n        <div class=\"wpj-jtoc--item-content\" data-depth=\"2\">\r\n                <a href=\"#podsumowanie\" title=\"Summary\" data-numeration=\"4\">Summary<\/a>\r\n                    <\/div> <\/li><\/ol>            <\/nav>\r\n                    <\/div>\r\n    <\/div>\r\n<\/div>\r\n\n\n\n<h2 class=\"wp-block-heading joli-heading jtoc-heading\" id=\"wstep\">Preface<\/h2>\n\n\n\n<p class=\"has-text-align-left has-large-font-size wp-block-paragraph\">Dlaczego wymieniam Bootcamp? Tam w&#322;a&#347;nie zacz&#281;&#322;a si&#281; idea &ldquo;projekt&oacute;w typu CRUD&rdquo; i rozpowszechni&#322;a si&#281; na pozosta&#322;e obszary internetu, a nast&#281;pnie by&#322;y one kopiowane i powielane. Czym jest CRUD i jak napisa&#263; jego kod wyja&#347;ni&#322;em w artykule <a href=\"https:\/\/www.juniorjavadeveloper.pl\/en\/2020\/04\/25\/pierwsza-klasa-jako-serwis-crud-kod-java-intellij-krok-po-kroku\/\" target=\"_blank\" rel=\"noreferrer noopener\">Pierwsza klasa jako serwis CRUD &ndash; kod Java, IntelliJ, krok po kroku<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading joli-heading jtoc-heading\" id=\"powtarzalnosc-i-powszechnosc-rozwiazan-powielanych-w-projektach\"><strong>Repeatability and universality of solutions replicated in projects<\/strong><\/h2>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph translation-block\"><strong>The first trap is the repeatability and universality of solutions duplicated in projects implemented at Bootcamp<\/strong>. Why is this such a big problem? Let's look at it from the perspective of a recruiter who reviews a large number of CVs. When a recruiter sees another project on your CV with a similar name and looks similar to the previous ones. You start to wonder what makes a given person stand out from others like them? Why should this CV go to the next stage of selection?<\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\">Tak, jak pisa&#322;em w <a href=\"https:\/\/www.juniorjavadeveloper.pl\/en\/2020\/02\/15\/jak-znalezc-pierwsza-prace-jako-junior-java-developer\/\">Jak znale&#378;&#263; pierwsz&#261; prac&#281; jako Junior Java Developer?<\/a> &ldquo;Osoba rekrutuj&#261;ca, przegl&#261;daj&#261;c CV, mo&#380;e stworzy&#263; dwie grupy jedna, to studenci, np. po studiach informatycznych, a druga grupa, to osoby ko&#324;cz&#261;ce Bootcamp. Niestety &bdquo;pierwsze&#324;stwo&rdquo; maj&#261; studenci.&rdquo;. Je&#380;eli nasze CV przejdzie do dalszego etapu, to nale&#380;y zrobi&#263; wszystko, aby wyr&oacute;&#380;ni&#263; si&#281; spo&#347;r&oacute;d innych z szablonem CRUD z Bootcamp. <\/p>\n\n\n\n<h3 class=\"wp-block-heading joli-heading jtoc-heading\" id=\"jak-rozwiazac-problem\"><strong>How to solve the problem?<\/strong>?<\/h3>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\"><strong>Jak rozwi&#261;za&#263; problem powszechno&#347;ci aplikacji CRUD powielanych na Bootcamp?<\/strong> Pisa&#322;em ju&#380; o tym w <a rel=\"noreferrer noopener\" href=\"https:\/\/www.juniorjavadeveloper.pl\/en\/2020\/02\/07\/wlasne-portfolio-jak-zbudowac-dobre-portfolio-i-gdzie-je-umiescic\/\" target=\"_blank\">W&#322;asne portfolio &ndash; jak zbudowa&#263; dobre portfolio i gdzie je umie&#347;ci&#263;?<\/a>. &ldquo;Dobre portfolio moim zdaniem powinno zawiera&#263; zar&oacute;wno jeden &bdquo;wi&#281;kszy&rdquo; projekt z wykorzystaniem Spring Framework jak r&oacute;wnie&#380; &bdquo;mniejsze&rdquo; projekty prezentuj&#261;ce np. w&#322;a&#347;ciwo&#347;ci j&#281;zyka Java. Projekt w Spring Framework, to niekoniecznie wspomniany wcze&#347;niej CRUD, je&#380;eli ju&#380; robimy CRUD&rsquo;a, to wa&#380;ne, aby mia&#322; on dobr&#261; dokumentacj&#281; w pliku READ.ME oraz sam kod zawiera&#322; testy jednostkowe, np. w JUnit i by&#322; zgodny z SOLID i DRY.&rdquo;. Rozwi&#261;zaniem jest po prostu nieszablonowy projekt.<\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\">Przyk&#322;ad nieszablonowego projektu opisa&#322;em w <a href=\"https:\/\/www.juniorjavadeveloper.pl\/en\/2020\/02\/15\/jak-znalezc-pierwsza-prace-jako-junior-java-developer\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jak znale&#378;&#263; pierwsz&#261; prac&#281; jako Junior Java Developer?<\/a>. &ldquo;Projekt b&#281;dzie sk&#322;ada&#322; si&#281; z aplikacji serwerowej i &#322;&#261;cz&#261;cej si&#281; z ni&#261; aplikacji mobilnej. Mo&#380;emy np. stworzy&#263; aplikacj&#281; mobiln&#261;, kt&oacute;ra dla bie&#380;&#261;cej pogody i lokalizacji przygotuje propozycj&#281; ubra&#324; na dany dzie&#324;. Brzmi skomplikowanie, ale tak na prawd&#281; nie jest.&rdquo;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading joli-heading jtoc-heading\" id=\"schematyczne-i-wierne-odzwierciedlanie-wyuczonego-szablonu\"><strong>Schematic and literal reflection of the learned template<\/strong><\/h2>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\"><strong>Pu&#322;apk&#261; numer dwa jest &ldquo;schematyczne i wierne odzwierciedlanie wyuczonego szablonu CRUD&rdquo;.<\/strong> Osoby, kt&oacute;re widz&#261; kod z artyku&#322;u <a rel=\"noreferrer noopener\" href=\"https:\/\/www.juniorjavadeveloper.pl\/en\/2020\/04\/25\/pierwsza-klasa-jako-serwis-crud-kod-java-intellij-krok-po-kroku\/\" target=\"_blank\">Pierwsza klasa jako serwis CRUD &ndash; kod Java, IntelliJ, krok po kroku<\/a> cz&#281;sto zadaj&#261; mi pytanie &ldquo;dlaczego tak pisa&#263; kod, a nie w spos&oacute;b jaki nauczy&#322;em si&#281; na Bootcamp lub z tutorial&rsquo;a?&rdquo;. Z takimi samymi pytaniami spotykam si&#281; podczas moich zaj&#281;&#263; z uczniami. <\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\">Let's think about the above questions. Why did I name the methods: create, read, update and delete, instead of: createCar, getCar, modifyCar, removeCar. Why didn't I use the Dto or Model suffix for the classes? Why is the main class called CarService and not CarCrud? I will answer the above questions in a moment, but first I will illustrate it using Java code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ 1. poprawna konwencja nazewnicza wed&#322;ug mnie\npublic class CarService {\n    public Car create(Car car) {\n        return null;\n     }\n}<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ 2. poprawna konwencja nazewnicza wed&#322;ug Bootcamp, tutorial\npublic class CarCrud {\n    public CarDto createCar(CarDto carDto) {\n        return null;\n     }\n}<\/pre>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\">In the code snippet above, the problem is the schematic approach to the naming convention. It's rare for different projects to have a naming convention that is the same or even similar to what we have seen in another project or been taught. A naming convention indicates, not dictates, how classes, methods, and variables should be named. This schematic approach obscures and blurs the meaning of creating a CRUD class.<\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\">Tak, jak pisa&#322;em w <a rel=\"noreferrer noopener\" href=\"https:\/\/www.juniorjavadeveloper.pl\/en\/2020\/04\/25\/pierwsza-klasa-jako-serwis-crud-kod-java-intellij-krok-po-kroku\/\" target=\"_blank\">Pierwsza klasa jako serwis CRUD &ndash; kod Java, IntelliJ, krok po kroku<\/a>: &ldquo;Bardzo wiele aplikacji jest tzw. CRUD&rsquo;ami, czyli udost&#281;pnia podstawowe operacje tworzenia (create), odczytu (read), modyfikacji (update) oraz usuwania (delete) obiekt&oacute;w jakiej&#347; klasy. Dla przyk&#322;adu we&#378;my katalog samochod&oacute;w, gdzie mamy klas&#281; Car.&rdquo;. W&#322;a&#347;nie na tym nale&#380;y si&#281; skupi&#263; i dostosowa&#263; szablon CRUD do projektu.<\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\">Wyja&#347;ni&#281; dlaczego &ldquo;1. poprawna konwencja nazewnicza wed&#322;ug mnie&rdquo; jest lepszym rozwi&#261;zaniem. Dodawanie &ldquo;Car&rdquo; do nazwy metody, co daje nam &ldquo;createCar()&rdquo; jest zb&#281;dne. Po pierwsze, dzia&#322;amy w obr&#281;bie klas CarService i przekazujemy do metody parametr typu &ldquo;Car&rdquo;, czyli create(Car car). Moim zdaniem jest, to wystarczaj&#261;ce, aby wiedzie&#263;, &#380;e metoda &ldquo;create()&rdquo; dotyczy obiekt&oacute;w klasy &ldquo;Car&rdquo;, czyli jest w kontek&#347;cie danej klasy. To jest powielanie ju&#380; istniej&#261;cych informacji, czyli tzw. mas&#322;o ma&#347;lane.<\/p>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph translation-block\">Of course, using names such as CarDto, CarModel, etc. makes sense if we are creating a multi-layer application, and I assume that we are creating one. Then we will have several different classes with the same name, e.g. Car. I wrote more about applications that have layers in <a rel=\"noreferrer noopener\" href=\"https:\/\/www.juniorjavadeveloper.pl\/2020\/05\/13\/aplikacje-java-maja-twarzy-jak-tort-urodzinowy- three-tier-app\/\" target=\"_blank\">Java applications have layers like a birthday cake - three-tier app<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading joli-heading jtoc-heading\" id=\"jak-rozwiazac-problem_1\"><strong>How to solve the problem?<\/strong>?<\/h3>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph translation-block\"><strong>How to solve the problem of schematically and faithfully reflecting a learned CRUD template?<\/strong> First of all, you should treat the template as a set of guidelines that solve a specific problem, and not as a way to solve all programming issues. It's like installing a door, you know that in most cases it will be a rectangle that should be mounted in the wall. Then the customer appears and says that they want it to be, for example, a sliding door with a window for his cats.<\/p>\n\n\n\n<h2 class=\"wp-block-heading joli-heading jtoc-heading\" id=\"podsumowanie\">Summary<\/h2>\n\n\n\n<p class=\"has-large-font-size wp-block-paragraph\">Creating CRUD applications should be practiced. You need to find several tutorials and courses showing how to do it and follow each of them. If possible, you can separate a common part from them and create your own recipe for a CRUD template.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-wp-embed is-provider-poradnik-dla-przysz-ych-junior-java-developer-039-w wp-block-embed-poradnik-dla-przysz-ych-junior-java-developer-039-w\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"gUPGJP6nVm\"><a href=\"https:\/\/www.juniorjavadeveloper.pl\/en\/kontakt\/\">Contact<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&bdquo;Kontakt&rdquo; &mdash; Poradnik dla przysz&#322;ych Junior Java Developer&amp;apos;&oacute;w\" src=\"https:\/\/www.juniorjavadeveloper.pl\/kontakt\/embed\/#?secret=aNJza4kc1k#?secret=gUPGJP6nVm\" data-secret=\"gUPGJP6nVm\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-wp-embed is-provider-poradnik-dla-przysz-ych-junior-java-developer-039-w wp-block-embed-poradnik-dla-przysz-ych-junior-java-developer-039-w\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"0fP5sfKgys\"><a href=\"https:\/\/www.juniorjavadeveloper.pl\/en\/mentoring-rezerwuj-termin\/\">Mentoring - book an appointment<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&bdquo;Mentoring &ndash; rezerwuj termin&rdquo; &mdash; Poradnik dla przysz&#322;ych Junior Java Developer&amp;apos;&oacute;w\" src=\"https:\/\/www.juniorjavadeveloper.pl\/mentoring-rezerwuj-termin\/embed\/#?secret=o0Abl16yYz#?secret=0fP5sfKgys\" data-secret=\"0fP5sfKgys\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>","protected":false},"excerpt":{"rendered":"<p>W tym artykule opisz\u0119 pu\u0142apki i zagro\u017cenia zwi\u0105zane z szablonem CRUD tworzonym w Spring Boot, kt\u00f3rego uczy si\u0119 na Bootcamp. Od razu zaznacz\u0119, \u017ce nie jestem przeciwnikiem Bootcamp&#8217;\u00f3w. Po prostu wiem z w\u0142asnego do\u015bwiadczenia z czym zmagaj\u0105 si\u0119 moi uczniowie, kt\u00f3rzy na Bootcamp nauczyli si\u0119 lub nie nauczyli jak tworzy\u0107 aplikacje CRUD z u\u017cyciem Springframework.Tak, [&hellip;]<\/p>","protected":false},"author":1,"featured_media":942,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_ppp_document_settings_meta":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[4,6,2,7],"tags":[],"class_list":["post-907","post","type-post","status-publish","format-standard","has-post-thumbnail","category-bez-kategorii","category-felieton","category-poczatkujacy","category-poradnik"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.juniorjavadeveloper.pl\/wp-content\/uploads\/2020\/08\/pulapki-szablonu-crud_naglowek.png","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/posts\/907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/comments?post=907"}],"version-history":[{"count":22,"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/posts\/907\/revisions"}],"predecessor-version":[{"id":3737,"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/posts\/907\/revisions\/3737"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/media\/942"}],"wp:attachment":[{"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/media?parent=907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/categories?post=907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.juniorjavadeveloper.pl\/en\/wp-json\/wp\/v2\/tags?post=907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}