шаблоны-проектирования

PHP design patterns

Help me understand the patterns php. There is a basic abstract class that defines the methods of the object's behavior. For e ... is currently being used. Can you tell me what is the best pattern to use, or can you give me an idea of how to implement it?

why do I need the factory pattern?

Why do I need the factory pattern? As far as I understand, the factory accepts a certain value as input, by which it is possi ... versatility, etc. provides polymorphism. what is the joy of writing a factory?Create a class(clusTer1), not a new clusTer1.

Adapter pattern in Java and exceptions

Hello. I'm trying to implement a common interface for two classes that return the same type of data, but do it in their own w ... established. In another class (LocalDataAdapter) method does not throw exceptions. How to unify the interface for this case?

The Prototype pattern.(from the Gang of Four")

The "Prototype" pattern is illustrated in the above book with the following example The motivation for using this pattern is ... nd copy the "prototype" if the client has already received a specific prototype in the constructor and can work with it work?

Design patterns in popular Open Source projects

Can someone give a list of common design patterns in Open Source projects ? Such as symfony or laravel ? For example, I woul ... look at the implementation of the Factory, Builder, Prototype, Adapter, Decorator, Observer, etc. patterns in these projects.

Patterns in Python

I have heard different opinions about patterns. I'm not talking about patterns in Python, but patterns in general. That half ... and Python is flexible enough not to need such tweaks? If it is worth studying them, then which 5-10 should be studied first?

What does bad code under the "Factory Method" pattern look like?

I am studying patterns and I have a problem that I can't find bad code that could be rewritten using the pattern "Factory met ... ample with the rationale for why in this example it is necessary to use the factory method and why it will be bad without it.

The "Factory Method" template. What are the advantages of this pattern?

On the page https://refactoring.guru/ru/design-patterns/factory-method it is written that the main task that this pattern sol ... Q: What is the difference between the two examples? What are the advantages of factories? Thank you in advance for your help.

Singleton in Python and del

There is an interesting post Singleton in Python I will add two more implementations, one from Beasley's book, the other from ... it possible to create a singleton in the program, and then delete and create another one? 2) how do I make __del__ work?

How to combine the "Strategy" pattern and the "Factory Method"?

When designing, I encountered a problem: different objects are created using the factory method. Each object can perform cert ... e so that the object performs only the actions peculiar to it. Do you need to create interfaces for each category of actions?

Singleton and static class

So I decided to see what a miracle this Singleton is. And the question immediately arose: how is it better than the static cl ... may be problems when editing the record. In this case, is it advisable to implement a form class in the form of a singleton?

Why shouldn't the repository return a DTO?

Everywhere they write that the repository should not return a DTO... What should I do then? return an object or an array? But ... for CRUD actions to have a layer for eloquent models, if I decide to replace them. Tell me, what is better to do in my case?

Applying the JS Module pattern

I would like to learn more about the methods of applying the Module pattern, if possible with real examples. Thanks.

What should a good C++application architecture look like? [closed]

Closed. It is impossible to give an objective answer to this question . Answers to it are not accepted at the moment. ... en source projects with a competent architecture that would understand what a good application architecture should look like?

The "Visitor" pattern. Java

For the first time I implement it, and something did not work. public interface FieldVisitor { Object visit(Field field) ... any way I can change this behavior? To call the function for the actual type, or did I get stuck with the pattern somewhere?

proxy vs decorator

Good time of day. In my question, I consider the proxy and decorator patterns exclusively in the context of the c++language. ... inherit the api of this site from its interface. So how do these two patterns differ? no wonder they are called differently?

Designing class interaction

The problem is accessing the methods and fields of the classes. After writing a certain class (public class A), we want to ac ... he children class (RichChildren) in order to get through it and use the get method. That's where I got completely confused...

Why do we need static methods and properties in php?

How is static methods and properties used in php? One application is the implementation of the singleton pattern. Are there ... be glad to see an example where using the factory method, a problem was solved that was more difficult to solve without it.

Problems with the `Singleton`pattern

While studying the Singleton pattern, I came across the fact that the classical implementation of this pattern is very lame i ... return Nested.instance; } private class Nested { internal static readonly Singleton instance = new Singleton(); } }

What are the differences and similarities between the Adapter, Decorator, Wrapper, and Proxy patterns?

Hello. I understand a little bit about design patterns, and I can't understand the difference in these patterns. In some plac ... ow the proxy differs from the decorator. PS Code examples are desirable to immediately see the differences and similarities.