tag:userecho.com,2024-03-28:/feeds/topics/en//Refactoring.Guru2024-03-24T11:21:50+00:00tag:feedback.refactoring.guru,2024-03-24:/communities/3/topics/5753-remove-middle-man-has-diagrams-from-hide-delegate/2024-03-24T11:21:50+00:002024-03-24T11:21:50+00:00Remove middle man has diagrams from hide delegate? [bugs] <p>I feel like <a href="https://refactoring.guru/remove-middle-man">https://refactoring.guru/remove-middle-man</a> resues diagrams from <a href="https://refactoring.guru/hide-delegate">https://refactoring.guru/hide-delegate</a>, just switches their position (suddenly the solution is a problem). Shouldn't "remove middle man" have completely different diagrams?</p><br/><br/> Hoang Tran replied:<br/><p>In these cases, we need to weight which solution we should go for. The first one is the middle man has too many methods that simply delegate to other objects while the second one wants to hide the delegate. Both problems are quite vague in my opinions. We should try both to see if it solves our current code design.</p>Petr Vnenkhttps://feedback.refactoring.guru/users/72255-petr-vnenk/topics/tag:feedback.refactoring.guru,2024-03-24:/communities/3/topics/5770-replace-temp-with-query-might-add-performance-overhead/2024-03-24T11:13:17+00:002024-03-24T11:13:17+00:00Replace Temp with Query might add performance overhead [questions] <p><img src="/s/attachments/13473/3/0/238de89f832f018a41a2292a0b405ff3.png"></p><p>I believe the first solution on the left is more efficient than the second as it caches the result of basePrice for reference in conditional expressions. Can you please explain why we should favour the second one ?</p><br/><br/>suggested by: Hoang TranHoang Tranhttps://feedback.refactoring.guru/users/72576-hoang-tran/topics/tag:feedback.refactoring.guru,2024-03-21:/communities/3/topics/1576-translate-turkish/2024-03-21T12:40:10+00:002024-03-21T12:40:10+00:00[Translate] Turkish [ideas] <p>A great web page and ebook, I think this should be translate to Turkish. If you want we can help you.</p><p></p><p>Have a good days.</p><br/><br/> Ender Ahmet Yurt replied:<br/><p>hey folks. how is it going? I can help you too if you need any help for translating the page to Turkish.</p>Alameddin Çelikhttps://feedback.refactoring.guru/users/4260-alameddin-celik/topics/tag:feedback.refactoring.guru,2024-03-21:/communities/3/topics/1327-ruby-support-for-the-refactor-course/2024-03-21T12:38:30+00:002024-03-21T12:38:30+00:00Ruby support for the refactor course [ideas] [under review]<p>I would love the refactoring course to support Ruby.</p><br/><br/> Ender Ahmet Yurt replied:<br/><p>+1 Please Ruby support for that course :)</p>Jesús Abarcahttps://feedback.refactoring.guru/users/3427-jesus-abarca/topics/tag:feedback.refactoring.guru,2024-03-09:/communities/3/topics/5748-please-put-examples-in-kotlin/2024-03-09T20:31:41+00:002024-03-09T20:31:41+00:00Please put examples in Kotlin [ideas] <p>It will be nice to have the examples in kotlin too</p><br/><br/>suggested by: cardaguhcardaguhhttps://feedback.refactoring.guru/users/72062-cardaguh/topics/tag:feedback.refactoring.guru,2024-02-29:/communities/3/topics/1881-translation-ozbekcha-uzbek-uzbekskij/2024-02-29T10:09:39+00:002024-02-29T10:09:39+00:00[Translation] O'zbekcha / Uzbek / Узбекский [ideas] [under review]<p>Я разработчик из Узбекистана. Можно ли добавить поддержку Узбекского языка. Я готов перевести.</p><br/><br/> Sirojxuja Muminkhodjaev replied:<br/><p>Здравствуйте!</p><p>Сколько голосов нужно для зеленого света))?</p>Islomhttps://feedback.refactoring.guru/users/5586-islom/topics/tag:feedback.refactoring.guru,2024-02-26:/communities/1/topics/5712-spasibo-za-knigu-i-materialyi-na-sajte/2024-02-26T16:13:25+00:002024-02-26T16:13:25+00:00Спасибо за книгу и материалы на сайте [praises] [thanks]<p>Спасибо за отличные материалы! С удовольствием прочитал и буду изучать дальше данные паттерны.<br><br>Заметил небольшой недочёт на схеме в Посетителе. Судя по всему вместо CompoundGraphic должен быть CompoundShape.</p><br/><br/> Alexander Shvets replied:<br/><p>Спасибо вам за отзыв!</p>Sergei Kuraksinhttps://feedback.refactoring.guru/users/68744-sergei-kuraksin/topics/tag:feedback.refactoring.guru,2024-02-23:/communities/3/topics/5721-an-example-of-switch-statement-smell-addressed-with-extract-method-and-move-method-refactoring/2024-02-23T12:01:16+00:002024-02-23T12:01:16+00:00An example of "switch statement" smell addressed with "extract method" and "move method" refactoring [questions] <p></p>Hello everyone, in <a href="https://refactoring.guru/smells/switch-statements">the switch statements smell page</a> , the first treatment is described as "To isolate <code>switch</code> and put it in the right class, you may need <a href="https://refactoring.guru/extract-method">Extract Method</a> and then <a href="https://refactoring.guru/move-method">Move Method</a>.".<br><br>I'm having a hard time finding, or coming up with such a problematic example, can someone show me one to help me understand it please ?<br><br>Thank you very much.<br/><br/>suggested by: josephjosephhttps://feedback.refactoring.guru/users/71411-joseph/topics/tag:feedback.refactoring.guru,2024-02-17:/communities/1/topics/4116-sajt-zablokirovan-v-rossii/2024-02-17T11:15:12+00:002024-02-17T11:15:12+00:00САЙТ ЗАБЛОКИРОВАН В РОССИИ [discussions] <p>Привет!<br><br>Сайт стал недоступен в России из-за блокировки Роскомнадзором.<br><br>С нашей стороны всё остаётся рабочим. Вы можете зайти на сайт с помощью VPN, весь контент и премиум покупки остаются доступными и рабочими.</p><p></p><br/><br/> eX replied:<br/><p>О как. А чё енота своего поменяли, уже не стенд виф уграин? Не актуально получается?</p>Alexander Shvetshttps://feedback.refactoring.guru/users/8529-alexander-shvets/topics/tag:feedback.refactoring.guru,2024-02-15:/communities/3/topics/5701-you-proposed-using-assertions-in-python-which-is-considered-code-smell-outside-of-testing/2024-02-15T16:12:58+00:002024-02-15T16:12:58+00:00You proposed using assertions in python, which is considered code smell outside of testing. [bugs] <p>In this post: <a href="https://refactoring.guru/introduce-assertion">Introduce Assertion (refactoring.guru)</a><br>The python version of the code uses "assert" keyword which is always discouraged from being used outside tests because all assertions can be easily bypassed with debugging flag.<br>So in production code this is a code smell in python, and instead a "raise" keyword should be used.</p><p></p><br/><br/>suggested by: Annoying AdamAnnoying Adamhttps://feedback.refactoring.guru/users/71101-annoying-adam/topics/tag:feedback.refactoring.guru,2024-02-12:/communities/3/topics/5677-how-about-design-patterns-used-in-functional-programming-instead-of-oop-say-typescript-with-no/2024-02-12T12:56:52+00:002024-02-12T12:56:52+00:00How about design patterns used in functional programming instead of OOP, say Typescript with no classes? [discussions] <p>How about design patterns used in functional programming instead of OOP, say React+Typescript with no classes?</p><p><br></p><br/><br/>suggested by: ritikaadit3+refactoringgururitikaadit3+refactoringguruhttps://feedback.refactoring.guru/users/70718-ritikaadit3refactoringguru/topics/tag:feedback.refactoring.guru,2024-02-12:/communities/3/topics/5680-refactoring-ternary-statements-using-ternaries-for-their-side-effects/2024-02-12T12:50:35+00:002024-02-12T12:50:35+00:00Refactoring: Ternary Statements: Using Ternaries for their Side Effects [ideas] [planned]<p>I think a great addition to the Conditionals portion of the Refactoring Guides would be to discourage using Ternary Expressions as Statements. This is highly discouraged, and you don't see it often, but it's been known to be present in some very, very legacy code. I've witnessed certain devs finding it in legacy code and using it because it's novel, and it tends to add to code clutter and can severely increase cognitive load when sifting through complex conditionals.</p><p><strong>Example:</strong></p><p><strong>DON'T:</strong></p><p></p><blockquote><pre>const foo = "bar";foo === "bar" ? quux() : zim();</pre></blockquote><p></p><p><strong>DO:</strong></p><p></p><blockquote><pre>const foo = "bar";if (foo === "bar") { quux()} else { zim();}</pre></blockquote><p></p><p></p><p></p><br/><br/> Alexander Shvets replied:<br/><p>Thanks!</p>Norpyxhttps://feedback.refactoring.guru/users/70762-norpyx/topics/tag:feedback.refactoring.guru,2024-02-12:/communities/3/topics/5683-refactoring-replace-temp-with-query-isnt-it-an-issue-when-debugging/2024-02-12T12:40:35+00:002024-02-12T12:40:35+00:00Refactoring - Replace Temp with Query - Isn't it an issue when debugging ? [discussions] [closed]Hi, and thanks for this site. <br><br>About "Replace Temp with Query", doesn't it pollute the debugging process ? How do you minimize the issues with that ? <br><br>Thanks<p></p><br/><br/> Alexander Shvets replied:<br/><p>Hi!<br><br>"Replace Temp with Query" is often an interim step in larger refactoring efforts aimed at simplifying and improving the design of the code. By replacing temporary variables with queries, you're not only making the code more modular but also preparing it for further refactorings that can significantly enhance its readability and maintainability. In this context, any initial increase in complexity or debugging difficulty is temporary and strategic.</p><p>As you progress with further refactorings, such as "Extract Method" or "Inline Method," the overall structure of the code becomes cleaner and more coherent, ultimately simplifying the debugging process. To minimize interim issues, focus on incremental testing and refactoring in small steps, ensuring each change preserves the functionality and improves the codebase's navigability.</p>Jaunehttps://feedback.refactoring.guru/users/70861-jaune/topics/tag:feedback.refactoring.guru,2024-01-22:/communities/3/topics/608-i-would-like-to-buy-a-printed-version-of-design-patterns-book/2024-01-22T21:07:51+00:002024-01-22T21:07:51+00:00I would like to buy a printed version of Design Patterns book! [ideas] [planned]<p>I do really enjoy your book. And would like to buy printed version to have it on my work place</p><br/><br/> Alexander Shvets replied:<br/><p>Hi!<br><br>Yes, you can print one copy for personal use as per the ebook license.</p>Sergii Aleksieievhttps://feedback.refactoring.guru/users/932-sergii-aleksieiev/topics/tag:feedback.refactoring.guru,2024-01-19:/communities/3/topics/5638-kurs-po-refaktoringu-pereklad-zanurennya-v-refaktoring-vvedennya-lokalnogo-rozshirennya/2024-01-19T10:56:17+00:002024-01-19T10:56:17+00:00Курс по рефакторингу. Переклад. Занурення в Рефакторинг -> Введення локального розширення [bugs] [fixed]<p><img src="/s/attachments/13473/3/0/5058a6d3f76a8853cc46b6e074f763e6.png"></p><br/><br/> Alexander Shvets replied:<br/><p>Дякую! Виправлю цей косяк із наступним оновленням.</p>Yanis Yeltsinhttps://feedback.refactoring.guru/users/34176-yanis-yeltsin/topics/tag:feedback.refactoring.guru,2024-01-18:/communities/1/topics/5640-malenkij-bazhok-v-typescript-primere-chain-of-responsibility/2024-01-18T08:44:37+00:002024-01-18T08:44:37+00:00Маленький бажок в Typescript примере Chain of Responsibility [bugs] Привет! Спасибо за прекрасный сайт<br><br>Есть небольшое уточнение. В интерфейсе и абстрактном классе <em>Handler и Abstract Handler</em> тип возвращаемого значения функции<em> handle() </em>указан как <em>string</em>:<br><br>Раз:<br><pre>interface Handler { setNext(handler: Handler): Handler; handle(request: string): string;}</pre><p></p><p>Два:</p><pre> public handle(request: string): string { if (this.nextHandler) { return this.nextHandler.handle(request); } return null; } </pre><p></p><p>Должно быть <em>string | null</em></p><br/><br/> Александр Трутанов replied:<br/><p>Либо как вариант в абстрактном хэндлере не null возвращать (это потребует изменения и в типах возвращаемых значений конкретных хэндлеров), а дефолтную строку в духе "Запрос остался необработанным"</p>Александр Трутановhttps://feedback.refactoring.guru/users/69953-aleksandr-trutanov/topics/tag:feedback.refactoring.guru,2024-01-15:/communities/39/topics/5620-/2024-01-15T10:59:03+00:002024-01-15T10:59:03+00:00有小伙伴知道书中的类图是用什么工具画的吗? [ideas] [completed]<p>书中的类图都比较简约想知道是用什么工具画的, 麻烦知道的小伙伴说一下.</p><br/><br/> Alexander Shvets replied:<br/><p>Hi!<br><br>Sorry for answering in English.</p><p>Thanks for asking! I used <a href="https://www.omnigroup.com/omnigraffle/">OmniGraffle</a> (sadly, only available on macOS) with heavily customized <a href="https://stenciltown.omnigroup.com/stencils/uml-25-collection/">UML stencils</a>.</p><p>The comics were drawn using Inkscape.</p>liu weikanghttps://feedback.refactoring.guru/users/8662-weikang-liu/topics/tag:feedback.refactoring.guru,2024-01-15:/communities/3/topics/5627-ui-issue-order-link-should-appear-under-folder-order-and-not-strategies/2024-01-15T10:53:24+00:002024-01-15T10:53:24+00:00UI Issue: 'Order' link should appear under folder 'order' and not 'strategies' [bugs] [fixed]UI issue.<br><br>What: On the right side of the screen, the file "Order" appears under the folder "strategies" but should appear under a folder named "order".<br>Where: Java example of the strategy design pattern<br>Direct link: <a href="https://refactoring.guru/design-patterns/strategy/java/example#example-0--order-Order-java">https://refactoring.guru/design-patterns/strategy/java/example#example-0--order-Order-java<br><br></a>Screenshot attached.<br><br><p><img src="/s/attachments/13473/3/0/a88f7c03aef454663bc5947714da7f2c.png"></p><p></p><br/><br/> Alexander Shvets replied:<br/><p>Thanks! I'll fix this with the next update.</p>Gareth Strettonhttps://feedback.refactoring.guru/users/69721-gareth-stretton/topics/tag:feedback.refactoring.guru,2024-01-11:/communities/3/topics/5621-need-help-in-understanding-the-prototype-design-pattern/2024-01-11T16:42:29+00:002024-01-11T16:42:29+00:00Need help in understanding the prototype design pattern [questions] What does the following statement means in prototype design pattern:<br><p>"When your objects have dozens of fields and hundreds of possible configurations, cloning them might serve as an alternative to subclassing."</p><p></p><p></p><br/><br/>suggested by: Saurabh JhaSaurabh Jhahttps://feedback.refactoring.guru/users/69362-saurabh-jha/topics/tag:feedback.refactoring.guru,2024-01-09:/communities/3/topics/5615-refactoring-to-patterns-from-the-same-named-book/2024-01-09T17:31:51+00:002024-01-09T17:31:51+00:00"Refactoring to patterns" from the same named book [ideas] Hello!<br><br>Please add so powerful refactorings to the catalog: <a href="https://www.industriallogic.com/xp/refactoring/catalog.html">https://www.industriallogic.com/xp/refactoring/catalog.html</a><p></p><br/><br/>suggested by: Serhii SmirnovSerhii Smirnovhttps://feedback.refactoring.guru/users/69598-serhii-smirnov/topics/tag:feedback.refactoring.guru,2024-01-09:/communities/1/topics/5540-kotlin/2024-01-09T08:00:17+00:002024-01-09T08:00:17+00:00Kotlin [ideas] Добавьте пожалуйста примеры на kotlin<p></p><br/><br/> Valentyn Berkatiuk replied:<br/><p>Зачем, если с помощью ии ты можешь переписать код на котлин, а пройдя курс ещё будешь знать что-то и на джаве</p>fsatybaldiyevhttps://feedback.refactoring.guru/users/68024-fsatybaldiyev/topics/tag:feedback.refactoring.guru,2024-01-08:/communities/3/topics/5612-demo-app-avec-patron-darchitecture-n-tiers/2024-01-08T08:01:24+00:002024-01-08T08:01:24+00:00Demo App avec patron d'architecture N-TIERS [questions] Bonjour, <br><br>Serait t-il possible d'avoir un Demo avec le patron d'architecture N-TIERS ( couche accès de données, couche d'affaires, Couche services et couche présentation) tout en appliquant certains patron de conceptions ?<br><br>Merci<p></p><br/><br/>suggested by: Ahmed Ben AliAhmed Ben Alihttps://feedback.refactoring.guru/users/67468-ahmed-ben-ali/topics/tag:feedback.refactoring.guru,2024-01-03:/communities/3/topics/5607-possible-missing-annotation-in-java-builder-example/2024-01-03T20:01:05+00:002024-01-03T20:01:05+00:00Possible missing annotation in Java Builder example [discussions] <p>I was just looking into an example of Java Builder pattern and I think that there is a missing annotation - <a href="https://refactoring.guru/design-patterns/builder/java/example#example-0--builders-CarBuilder-java">Builder in Java / Design Patterns (refactoring.guru)</a>.<br>In <em>CarBuilder </em>there is an implemented method <em>setCarType</em> from an interface, but it doesn't have @Override annotation whereas in other implementations it has this annotation. I know this annotation is not mandatory, but it's a good practice and since it is used with every other method and other implementations, I thought it could be added. Or is there a reason that this annotation wasn't used that I have missed?</p><p><img src="/s/attachments/13473/3/0/9d1a7373c5e7e455beb5431eff14787f.png"></p><p><img src="/s/attachments/13473/3/0/82c57b3072abb0bfd718ed04952811a8.png"></p><p></p><br/><br/>suggested by: Jakub WodeckiJakub Wodeckihttps://feedback.refactoring.guru/users/69347-jakub-wodecki/topics/tag:feedback.refactoring.guru,2023-12-25:/communities/3/topics/5585-decorator-pattern-get-specific-decorator/2023-12-25T11:59:19+00:002023-12-25T11:59:19+00:00Decorator pattern get specific decorator [questions] [under review]So I have a list of decorators, including a Color Decorator. This determines if there is a color shown. Showing this color poses a challenge since I can't get a specific decorator unless adding a getDecorator function to each decorator. Does anyone have some tips on how to make this simpler or straight forward?<p></p><br/><br/> Alexander Shvets replied:<br/><p>Sorry, I'm still not sure I understand your case. By stacking, I mean that each decorator may affect the outcome of the thing it decorates, and if multiple decorators are stacked together, you get a complex result. For the IsOpen() behavior each decorator would override the true/false result of the previous decorator (which, arguably, makes a little sense).<br><br>I could imagine a good case for this if your color decorators stack, and this results into a mixed color from some sort of getColor() method. So, if you have blue, and then yellow, you get the green color in the end (but I'm not sure whether it's what you want). But I have hard time understanding the case where you have color decorators and HasZombie decorator. What is the supposed behavior that is common to both?<br><br>If you can explain what you're trying to achieve without mentioning any patterns, that might be a better start of this discussion.<br></p>Taziohttps://feedback.refactoring.guru/users/68859-tazio/topics/tag:feedback.refactoring.guru,2023-12-23:/communities/3/topics/5582-vdguk-pro-knigu-zanurennya-v-paterni-proektuvannya/2023-12-23T11:06:10+00:002023-12-23T11:06:10+00:00Відгук про книгу "Занурення в патерни проектування" [praises] [thanks]Дуже класний та якісний матеріал<br>Велика подяка автору за його старання, це дуже цінно<p></p><br/><br/> Alexander Shvets replied:<br/><p>Дякую, Вадиме!</p>Vadim Lubomlhttps://feedback.refactoring.guru/users/60138-vadim-luboml/topics/tag:feedback.refactoring.guru,2023-12-12:/communities/3/topics/5552-design-pattern-for-event-driven-architecture/2023-12-12T11:40:52+00:002023-12-12T11:40:52+00:00design pattern for event driven architecture [ideas] [planned]since the event driven systems have become viable solution to nowadays problems, should the website have a section for this like the following ones listed here <a href="https://blog.bitsrc.io/5-essential-distributed-systems-design-patterns-for-event-driven-architectures-fbce0a51b886">https://blog.bitsrc.io/5-essential-distributed-systems-design-patterns-for-event-driven-architectures-fbce0a51b886</a> <p></p><br/><br/> Alexander Shvets replied:<br/><p>Thanks, I'll add it to my TODO.</p>Jonathan Filippinihttps://feedback.refactoring.guru/users/68270-jonathan-filippini/topics/tag:feedback.refactoring.guru,2023-11-14:/communities/3/topics/5506-chomu-v-nota-pila-zamst-ruki/2023-11-14T18:38:36+00:002023-11-14T18:38:36+00:00чому в єнота пила замість руки??? [questions] <p>чому в єнота пила замість руки???</p><br/><br/>suggested by: Ivan_Ivan_https://feedback.refactoring.guru/users/67127-ivan-/topics/tag:feedback.refactoring.guru,2023-11-13:/communities/3/topics/5500-please-write-a-book-on-migration-patterns-strangler-bluegreen-etc/2023-11-13T15:32:18+00:002023-11-13T15:32:18+00:00Please write a book on migration patterns (strangler, blue/green, etc.)!! [ideas] [under review]<p></p>Would love to see a book in the same style on migration patterns from Martin Fowler et al. Love your playful and visual way of making things simple and easy to apply!<br/><br/> Alexander Shvets replied:<br/><p>Hi! Thanks for the idea!</p>Tyson Graaffhttps://feedback.refactoring.guru/users/39107-tyson-graaff/topics/tag:feedback.refactoring.guru,2023-11-06:/communities/39/topics/2293-/2023-11-06T17:16:03+00:002023-11-06T17:16:03+00:00重构有翻译计划嘛 [ideas] [planned]<p>中国读者期待重构的翻译呢</p><br/><br/> Jianjun Xiao replied:<br/><p>这都3年了,请问有计划吗</p>邀月https://feedback.refactoring.guru/users/7356-/topics/tag:feedback.refactoring.guru,2023-10-27:/communities/3/topics/503-design-patterns-with-a-functional-approach/2023-10-27T07:05:58+00:002023-10-27T07:05:58+00:00Design Patterns with a functional approach [ideas] [planned]<p>Hi, would you be looking to update the Java code examples to use the more modern Java 8 idioms? For example, in the Decorator pattern you can use a more functional approach. It would be good to describe both ways as each as an advantage. </p><br/><br/> João Mota replied:<br/><p>Hello!<br>Any updates here, please?</p>Zenko Turekhttps://feedback.refactoring.guru/users/710-zen/topics/tag:feedback.refactoring.guru,2023-10-22:/communities/3/topics/5463-architectural-patterns/2023-10-22T17:16:04+00:002023-10-22T17:16:04+00:00Architectural patterns [ideas] [planned]Would it be possible to add architectural patterns as content section?<p></p><br/><br/> Alexander Shvets replied:<br/><p>Hi!<br><br>Thanks for the idea, I plan to add them eventually.</p>Daniel Pomajbíkhttps://feedback.refactoring.guru/users/66185-daniel-pomajbik/topics/tag:feedback.refactoring.guru,2023-10-18:/communities/3/topics/5449-add-pipeline-of-pipe-filter-pattern/2023-10-18T19:26:52+00:002023-10-18T19:26:52+00:00Add pipeline (of pipe-filter) pattern. [ideas] [planned]It is possible to add that pattern?<p></p><br/><br/> Alexander Shvets replied:<br/><p>Hi!<br><br>I'll add this to my todo list, thanks!</p>cyberpol_777https://feedback.refactoring.guru/users/66037-cyberpol-777/topics/tag:feedback.refactoring.guru,2023-10-01:/communities/3/topics/5411-memento-state-encapsulation/2023-10-01T09:45:51+00:002023-10-01T09:45:51+00:00Memento: State Encapsulation. [ideas] Instead of having the Memento and the Object coupled on private attributes being declared in both classes (State). We can encapsulate these elements in a State object with a known interface, hence different states can be used and classes are less coupled.<p></p><br/><br/>suggested by: TorkyTorkyhttps://feedback.refactoring.guru/users/65379-torky/topics/tag:feedback.refactoring.guru,2023-09-29:/communities/3/topics/5408-would-a-section-on-monads-be-possible-i-find-your-diagrams-very-useful/2023-09-29T07:00:05+00:002023-09-29T07:00:05+00:00Would a section on Monads be possible? I find your diagrams very useful! [ideas] Hi there!<br><br>I have been seeing a lot of videos on Monads recently and have been fascinated with how they work. Most videos do well in explaining it however I find your diagrams easier to understand. I have attached the basic Wikipedia article, and two videos that I think made my understanding clearer. On another note: Thank you for this website, it has made understanding and explaining design patterns to others much easier!<br><br>Wikipedia: <a href="https://en.wikipedia.org/wiki/Monad_(functional_programming)">en.wikipedia.org/wiki/Monad_(functional_programming)<br><br><iframe allowfullscreen="" frameborder="0" src="//www.youtube.com/embed/C2w45qRc3aU"></iframe><iframe allowfullscreen="" frameborder="0" src="//www.youtube.com/embed/VgA4wCaxp-Q"></iframe><p><br></p></a><p></p><br/><br/>suggested by: SamSamhttps://feedback.refactoring.guru/users/65306-sam/topics/tag:feedback.refactoring.guru,2023-09-26:/communities/40/topics/4602-/2023-09-26T11:07:13+00:002023-09-26T11:07:13+00:00关于俄乌战争 [exhibit] 不要觉得是俄罗斯总统疯了,你要想想你们的总统是不是疯了。<br>难道一定要等乌克兰被北约军队覆盖,俄罗斯才能发动战争?<br>2014的克里米亚已经是对乌克兰的一种警告,然而乌克兰不寻求一种和平解决的方式,<br>而是继续咄咄逼人。<br>我认为现在俄罗斯的处境比你们的西方更惨,我认为俄罗斯是被逼的。<br>当然因为最受伤的是乌克兰的人民,所以你从你的出发点抱怨这件事情,我很理解。<br>但是请你还是要认清事实。<p></p><br/><br/> 大字 replied:<br/><p>这就像是一条疯狗坐在树下面,你和疯狗相安无事,但是你执意要过去踩这条狗的尾巴。</p><p>实际上日常人际关系中也不乏类似的事出现,A一直在暗中欺负B,B明面上反抗,然后所有人只看到B对A无礼,全都谴责B,这叫做reaction abuse</p>capture showers_0thttps://feedback.refactoring.guru/users/49509-capture-showers-0t/topics/tag:feedback.refactoring.guru,2023-09-21:/communities/3/topics/4904-question-regarding-the-example-for-decorator-in-pythons-class-static-variable-component/2023-09-21T13:04:50+00:002023-09-21T13:04:50+00:00Question regarding the example for Decorator in Python's class-static variable (_component) [ideas] <p>Hey there great folk,<br>Consider the following example for the Decorator pattern in Python: <a href="https://refactoring.guru/design-patterns/decorator/python/example">https://refactoring.guru/design-patterns/decorator/python/example</a></p><p>The section that defines the decorator can starts like this:<br></p><pre>class Decorator(Component): _component: Component = None def __init__(self, component: Component) -> None: self._component = component @property def component(self) -> Component: return self._component def operation(self) -> str: return self._component.operation()</pre><p><br>Is the <strong>_component </strong>necessary? Can't we just remove it together with the <strong>@property</strong> method and just initialize it to None inside the __init()__ method?<br></p><pre>class Decorator(Component):<br> def __init__(self, component: Component = None) -> None:<br> self.component = component<br><br> def operation(self) -> str:<br> return self.component.operation()<br></pre><p></p><p>Enlighten me.</p><br/><br/> Sam Wareing replied:<br/><p>To be honest, the Python decorator example is just not how it is done in Python at all. This is all you need:<br><br></p><pre>import functoolsfrom typing import Callabledef custom_decorator(func: Callable): @functools.wraps(func) def _decorator(*args, **kwargs): # pre-call decorating functionality value = func(*args, **kwargs) # post-call decorating functionality return value return _decorator@custom_decoratordef decorated_function(): # do something ...<br></pre>Dozhamhttps://feedback.refactoring.guru/users/55354-dozham/topics/tag:feedback.refactoring.guru,2023-09-17:/communities/39/topics/5382-/2023-09-17T13:04:53+00:002023-09-17T13:04:53+00:00请问,电子书跟网站上的文章在内容上有什么差别? [ideas] [completed]<br/><br/> Alexander Shvets replied:<br/><p>你好!<br><br>这是个很好的问题,很多人都问过我。网站中确实包含了书中的所有模式。我原本可以在本书发布后减少免费内容,但是我特意决定不这样做。我希望这不会显得是自我夸耀,但并非所有人都有能力购买本书,而我不希望他们因此无法获得这些知识。<br><br>与此同时,除了我对你为本项目做出支持表示真挚感谢之外,购买本书后你还将获得一些实际的功能。<br><br><strong>额外内容(深入设计模式):</strong><br><br>• 本书包含介绍面向对象程序设计和统一建模语言(UML)主要术语的章节。其重点关注对象是初学者,但从我的个人经验来讲,即便是经验丰富的编程老手也能从花时间来复习这些内容中获益。<br><br>• 本书重点讲解了模式所遵循的 8 个设计原则(包括 SOLID)。这部分和上述术语部分大约占本书 60 页(全书共 406 页)左右的篇幅。<br><br>• 本书还包括大量 C#、C++、Go、Java、PHP、Python、Ruby、Rust、Swift 和 Typescript 的代码示例,你可以用 IDE 来打开、编译和试用它们。<br><br><strong>以下是电子书版本相对于网站的优势:</strong><br><br>• 离线访问。你可将电子书下载到手机或平板电脑中,这样即使在没有互联网连接时(比如在度假小屋、海滩、地铁和飞机上时)也能随时阅读。<br><br>• 阅读进度记录。大部分电子阅读设备和应用都能记录你的阅读进度,让你能从上次离开的位置继续阅读。如果你利用工作休息或通勤的零碎时间进行学习的话,这会很有帮助。当在网站上阅读时,你必须自己记住读到了哪里。<br><br>• 夜间模式。当前绝大多数电子阅读设备和应用都提供夜间模式(亮色文字和深色背景),这让你能非常方便地在床上进行阅读。为了优化本书在深色背景上的显示效果,我可是花了不少精力(夜间风格,特别是图像和图表的边框)。<br><br><br>我想你或许还有一些关于重构课程的问题。它不是一本电子书,你需要在浏览器中进行学习。以下是该课程的额外内容列表:<br><br><strong>额外内容(深入重构)</strong><br><br>• 实际示例。每种重构技巧的扩展示例。每个示例都会逐步演示如何清理“丑陋”的代码。<br><br>• 完成证书。你可在简历中包含证书来提升简历的含金量。<br><br><strong>其他优势:</strong><br><br>• 课程是简单的线性结构,可保存你的学习进度。这种学习方式比在网站上到处“晃悠”要更能发挥你的专注力。<br><br>• 购买了课程的用户可以随时在论坛上向我提出任何关于课程资料的问题。<br><br>• 最后,你用真金实银支持自己学习的事实将激励你完成课程。人们通常不会认真对待免费的东西,从而无限期地推迟学习。<br><br>无论如何,我希望这些解答能对你有所帮助。如果你有进一步的问题,请随时告诉我,我非常高兴能够为你提供帮助。<br><br>祝一切顺利,<br>亚历山大·什韦茨</p>jerry lloydhttps://feedback.refactoring.guru/users/64817-jerry-lloyd/topics/tag:feedback.refactoring.guru,2023-08-30:/communities/3/topics/5341-why-is-data-class-considered-a-code-smell/2023-08-30T21:04:44+00:002023-08-30T21:04:44+00:00Why is data class considered a code smell? [discussions] <p></p>Hello,<br><br>Thank you for all the work on the website. I really enjoy learning and repeating the patterns with Refactoring Guru :)<br><br>However, I would like to ask why data class is code smell in your opinion? This notion is similar to entities or DTOs, in my opinion data classes serve their purpose as representing a read-only entity in the system. Also, I don't understand the treatment part.<br><br>For example, in a silly language like JS/TS, let's say that I want to map an API response to something "real", rather than using plain Record<string, unknown> or whatever. I want to represent the data coming from the outside and map it to something tangible, possibly with some additional getters to get the derived data from it - actually to keep the code organized.<br><br>My humble question is: why is that bad? Why should I feel bad about using this pattern? What is the alternative? Some languages actually encourage use of data classes, for example Python or Kotlin. I don't understand the treatment and payoff here. Do you have some examples?<br><br>Kind regards,<br>Ralf<br/><br/>suggested by: maqibjbd5maqibjbd5https://feedback.refactoring.guru/users/64027-maqibjbd5/topics/tag:feedback.refactoring.guru,2023-08-30:/communities/3/topics/5344-return-early-pattern/2023-08-30T20:58:28+00:002023-08-30T20:58:28+00:00Return Early Pattern [ideas] [under review]Add <strong>Return Early Pattern</strong><br><br>I found this here <a href="https://medium.com/swlh/return-early-pattern-3d18a41bba8">https://medium.com/swlh/return-early-pattern-3d18a41bba8</a><p></p><br/><br/> Alexander Shvets replied:<br/><p>Hi!<br><br>Thanks, I think this all looks like good old guard clauses:<br><a href="https://refactoring.guru/es/replace-nested-conditional-with-guard-clauses">https://refactoring.guru/es/replace-nested-conditional-with-guard-clauses</a></p>Adam Gąsowskihttps://feedback.refactoring.guru/users/36346-gander-gasowski/topics/tag:feedback.refactoring.guru,2023-08-30:/communities/3/topics/5346-code-smell-man-in-the-middle-type-in-self-encapsulation-refactoring/2023-08-30T20:56:24+00:002023-08-30T20:56:24+00:00Code smell "man in the middle" type in Self-Encapsulation refactoring? [discussions] <p>Hello,<br>In the page <a href="https://refactoring.guru/self-encapsulate-field">Self Encapsulate Field (refactoring.guru)</a>, you advise to create a private getter for private field, to be used inside the private scope of a class.<br>It looks alot like a "man in the middle", given that the private fields stays read+write accessible, the getter is just an unconvenient way of reading the value.<br><br>I get it for a public getter field (<a href="https://refactoring.guru/encapsulate-field">Encapsulate Field (refactoring.guru)</a>), but self-encapsulation kinda smells bad, makes the code less readable and harder to maintain.<br>What's the point?<br><br>I'm all open to argument on this topic tho. :)<br><br>Regards,<br>Gweltaz.</p><p></p><br/><br/>suggested by: DinosaureDinosaurehttps://feedback.refactoring.guru/users/64090-dinosaure/topics/tag:feedback.refactoring.guru,2023-08-30:/communities/3/topics/4897-write-a-book-about-unit-testing-with-this-incredible-format-you-use/2023-08-30T15:09:37+00:002023-08-30T15:09:37+00:00Write a book about unit testing with this incredible format you use [ideas] I'm a huge fan of the way you make information digestible and entertaining. I think we all need a unit test book like that :)<p></p><br/><br/> Rashad Rivera replied:<br/><p>Alexander Shvets,<br><br>First, let me say your site and PDF are fantastic. Like others on this forum, I would also pay top dollar for a printed hard copy to add to my book collection. I sport your site every chance I get with new developers. The concepts are solid and based on good programming theory. The animations are the icing on the cake. They resonate with an old guy like me down to my young kids. Your work transcends. <br><br>Concerning the unit testing, I think you should add the theory to your topics because part of having good code is the ability to refactor it without breaking it. As you mentioned in your "Refactoring" section, a good refactor must have tests. <br><br>Perhaps you would consider starting key concepts that every unit test should have. Below are just a few suggestions for Unit Test Code Smells. =)<br></p><ol><li>Avoid testing implementation details.</li><li>Avoid testing too many layers (AKA integration testing)</li><li>Avoid testing multiple things.</li><li>The Triple A(s) (Arrange, Act, Assert)</li></ol><p></p><p>If you need help, I can volunteer my time. <br></p>Dante Pozo Castrohttps://feedback.refactoring.guru/users/50785-dante-pozo-castro/topics/tag:feedback.refactoring.guru,2023-08-16:/communities/40/topics/4433-jodete-ucrania/2023-08-16T12:22:27+00:002023-08-16T12:22:27+00:00Jodete Ucrania [exhibit] <p></p>El precidente de Rusia no esta loco lo que pasa es que el esta arto de las mierdas de EEUU y no aguanta que se crean dueños del mundo, yo soy cubano y tu te quejas de que el internet esta lento. Toda esa historia tuya es pura propaganda politica y yo no soy una oveja debil de mente, yo entiendo que todo conflicto tiene una cara oculta que responde a intereses mayores.<br/><br/> Carlos W. Mercado replied:<br/><p>¿Sos cubano y defendés a Rusia? Qué raro... ¿Dónde vivís? Falta que me digas que en la isla...</p><p>Como sea, está muy mal y errado que le digas a Ucrania que se joda, capaz en lo político podés decir tal cosa, sin demasiado pensamiento, pero tené presente que mucho del pueblo ucraniano ha sufrido por esta guerra (merecida o no). Capaz decir "Jodete Ucrania" no es tan buena idea.</p>erian971114https://feedback.refactoring.guru/users/46010-erian971114/topics/tag:feedback.refactoring.guru,2023-07-18:/communities/39/topics/5252-go/2023-07-18T11:20:54+00:002023-07-18T11:20:54+00:00廖显东所著的「Go 语言设计模式」,有大量抄袭「深入设计模式」中文版的段落 [questions] [under review]<p>在介绍设计模式时与本书基本或完全一致。</p><p><img src="/s/attachments/13473/39/0/7d7fdd7a7182021bb41141a9e6a20719.png"></p><br/><br/> Alexander Shvets replied:<br/><p>Hi!<br><br>Thank you for letting me know! It's a shame that the author did such a blatant steal. I'll pass it on to my Chinese lawyers, we'll see what we can do. Thank you!</p>Takeshihttps://feedback.refactoring.guru/users/62345-takeshi/topics/tag:feedback.refactoring.guru,2023-07-10:/communities/3/topics/5226-add-null-object-pattern/2023-07-10T10:03:22+00:002023-07-10T10:03:22+00:00Add Null Object Pattern [ideas] [planned]Вітаю, нещодавно я зіткнувся з проблемою великої кількості null полів у Response з Third-Party API, та читавши книгу Head First Design Pattern, я знаю, що в данному випадку Null Object Pattern був би дуже дотепним, передаючи стандартні значення всіх полів. Та зайшовши на Вас сайт, я не знайшов цього паттерна. Знати всім про нього було би дуже корисно!<p></p><br/><br/> Alexander Shvets replied:<br/><p>Дякую за пропозицію! Додам в TODO.</p>Vlad Shtaiierhttps://feedback.refactoring.guru/users/61136-vlad-shtaiier/topics/tag:feedback.refactoring.guru,2023-07-03:/communities/3/topics/5231-singleton-examples-from-the-java-api/2023-07-03T20:07:19+00:002023-07-03T20:07:19+00:00Singleton Examples from the Java API [questions] The examples from the Java API for the Singleton design pattern mention:<br>java.lang.Runtime#getRuntime()<br>java.awt.Desktop#getDesktop()<br>java.lang.System#getSecurityManager()<br><br>I don't understand the 3rd example.<br>System has a private constructor but no point of access.<br>SecurityManager has a public constructor.<br>Therefore neither are Singletons. Right?<p></p><br/><br/>suggested by: KrokodylKrokodylhttps://feedback.refactoring.guru/users/61890-krokodyl/topics/tag:feedback.refactoring.guru,2023-06-26:/communities/3/topics/4870-hello-could-you-please-add-abap-language-to-code-examples-i-also-can-give-you-a-hand/2023-06-26T07:37:34+00:002023-06-26T07:37:34+00:00hello, could you please add abap language to code examples ? i also can give you a hand [ideas] <p>hello, could you please add abap language to code examples ? i also can give you a hand</p><br/><br/> Martin Jonen replied:<br/><p>That is a fantastic idea. Also looking forward to see some ABAP examples. I am also able to support with this. <br></p><p>Cheers,</p><p>Martin</p>aelgendi89https://feedback.refactoring.guru/users/54677-aelgendi89/topics/tag:feedback.refactoring.guru,2023-06-16:/communities/3/topics/5198-change-render-method-name-for-button-interface-in-factory-pattern-article/2023-06-16T15:06:50+00:002023-06-16T15:06:50+00:00Change `render()` method name for Button interface in Factory pattern article [ideas] <p></p>Considering the similarity between `implements` vs `depends` UML connector, I think it can be confusing having both `Dialog` both `Button` expose a method with the same name `render`.<br>At a quick glance the diagram could be misread as if Dialog actually implements Button's `render()` method, instead of shipping one of its own.<br><p><img src="/s/attachments/13473/3/0/566c43cff9693c249e2140cf0c030148.png"></p><br/><br/>suggested by: 4javier4javierhttps://feedback.refactoring.guru/users/61252-4javier/topics/tag:feedback.refactoring.guru,2023-06-13:/communities/3/topics/5180-i-cant-access-the-website/2023-06-13T21:07:24+00:002023-06-13T21:07:24+00:00I can't access the website. [bugs] [fixed]<p> I can't access the website. What happened? Is it Ok?</p><br/><br/> Alexander Shvets replied:<br/>park jisunhttps://feedback.refactoring.guru/users/53220-/topics/tag:feedback.refactoring.guru,2023-05-25:/communities/3/topics/5155-bridge-vs-adapter/2023-05-25T20:35:44+00:002023-05-25T20:35:44+00:00Bridge vs Adapter [questions] [under review]<p></p>I understand that these patterns have different intentions, but still have some issues grasping them. Does bridge pattern is a subset of adapter? Because to me both of them look alike. I know that the adapter adapts one interface to another, but bridge also does the same (in example with devices and remotes we see that). Any suggestions on how should these patterns should be distinguishable?<br/><br/> Yurii B replied:<br/><p>Ok, I see. Viewing the same problem under different angles helps to understand problem deeper. Thank you very much for your time :)<br></p><p></p>Yurii Bhttps://feedback.refactoring.guru/users/23496-yurii-b/topics/tag:feedback.refactoring.guru,2023-05-23:/communities/3/topics/5058-bridge-v-abstract-factory/2023-05-23T15:40:55+00:002023-05-23T15:40:55+00:00bridge .v. abstract factory [questions] For a given domain problem, say making shapes using different implementation (say to be drawn on a screen or displayed on a projector) it may be clear to use Bridge (abstraction variation de-coupled from implementation variation). However if the domain is perhaps making different types of houses using different materials (e.g. building from bricks or from straw) then would we consider AbstractFactory as an option (as well as Bridge)? If we then shift the domain problem a little further to say a Bakery that produces pie & pastry products with apple or banana fillings (so a family of fruit fillings across each product), we perhaps go for AbstractFactory in preference to Bridge. <br><br>So it seems, there's a spectrum where Bridge may be best and where AbstractFactory may be best, for very similar domain problems.<br><br>My question is how to differentiate when to use Bridge and when to use AbstractFactory?<p></p><br/><br/> Yurii B replied:<br/><p>Well, they are different patterns: one for structuring stuff, other for creating stuff. So in case of abstract factory you want to create a family of product. Bridge in other hand is for separating two hierarchies or product families that can evolve independently (nothing creating here, just structuring stuff). You can think of an abstract factory that produces two hierarchies that later can be combined by bridge or something like that (doesn't feel right but still possible :) ) </p>HEChttps://feedback.refactoring.guru/users/58200-hec/topics/