• The factory method of PHP design pattern


    The PHP factory method provides a factory class for each product. Create different product instances through different factory instances. Compared with a simple factory, creating objects is no longer left to a class: split the simple factory, each product is implemented by a special simple factory, and each simple factory implements the factory interface class. […]

  • Understanding differentiation: simple factory pattern, factory method pattern, abstract factory pattern


    preface Many people don’t understand the difference between simple factory mode, factory method mode and abstract factory mode. It’s hard to see the theory. What should we do? Here, we do not mention too many theories, but only from the perspective of code structure, we provide a framework thinking, as follows: Simple factory model Class […]

  • JavaScript – Design Patterns


    1. Factory mode The so-called factory mode is to produce similar products repeatedly like a factory. Factory mode only needs us to pass in the correct parameters to produce similar products; we often use the same class constructor. Every time you use the derived class, a new instance is generated. Of course, there are many […]

  • 4. Design pattern builder pattern


    role The idea of the former name of the builder, that is, the person who builds a house, is a concept from the field of construction engineering, which includes three main roles: Builder: different kinds of workers, such as laying foundation, building beams, interior decoration, etc; Concrete builder: specific workers corresponding to each type of […]

  • Spring — implementation of IOC based on simple factory pattern and reflection


    The character of the waves is that they have been broken by the rocks for countless times and rushed to the rocks for countless flashesLike again to develop good habits To understand the principle of IOC implementation, we need to understand the reflection mechanism and factory mode What is the reflex mechanism In the Java […]

  • Analysis of spring IOC and its startup principle


    IOC summary 1. Overview of IOC There are three questions What is IOC Why use it How to use it? What is 1.1? Two concepts:Inversion of control, dependency injection Let’s take a look at the traditional way of working: on the basis of the principle of single responsibility of objects, an object rarely does its […]

  • Talking about JavaScript Design Patterns (1)


    introduction Design pattern classification Common design patterns Singleton mode Observer model Factory model Strategy model proxy pattern introduction JavaScript Design Patterns, a pattern is a reusable solution. When the code is built on the effective pattern, we can spend less time to care about our code structure, so we can spend more time to pay […]

  • C # design pattern


    Definition and classification of design patterns definition Design pattern: design pattern is a kind of summary of code design experience, and it is also a technology of documenting the solutions of design problems in software system. Using design patterns can reuse code, make it easier for others to understand and improve the reliability of code. […]

  • Factories in design patterns


    Factories in design patterns Intro There are several factory patterns in design patterns. Let’s talk about the usage and examples of these factory patterns. Factory patterns include simple factory, abstract factory and factory method, which are all creative patterns,The so-called creation pattern means that these design patterns are used to create objects. Simple factory First […]

  • Abstract factory code examples of PHP design patterns (3)


    objective The advantage over the simple factory pattern is that you can create an object by subclassing it in different ways. For a simple example, this abstract class might just be an interface. This pattern is a “real” design pattern because it realizes the “dependency inversion” of “d” in the s.o.l.i.d principle. This means that […]

  • Simple factory code examples of PHP design pattern (7)


    objective Simple factory mode is a simplified version of factory mode. The biggest difference between it and static factory mode is that it is not “static”. Because it is not static, you can have multiple factories with different parameters for which you can create subclasses. You can even mock it, which is crucial for writing […]

  • Static factory code examples of PHP design patterns (9)


    objective Similar to the abstract factory pattern, this pattern is used to create a series of related or interdependent objects. The difference between static factory mode and abstract factory mode is that only one static method is used to create all types of objects. This method is usually named factory or build. example Zend Framework:Zend_ […]