Tag:decorate

  • Structural design mode of detailed design mode — adapter and decorator

    Time:2022-5-4

    Structural design mode Creative design pattern is mainly to solve the problem of creating objects, while structural design pattern is to solve the problem of using existing objects. Adapter mode The adapter mode is easy to understand because it is very common in our daily life, such as headphone conversion cable, charger adapter, socket, etc. […]

  • Introduction to typescript mixins

    Time:2022-4-27

    Mixins In addition to the traditional OO hierarchy, another popular way to build classes from reusable components is to build them by combining simpler partial classes. You may be familiar with the idea of mixins or features in languages such as Scala, and this pattern is also popular in the JavaScript community. The pattern relies […]

  • Caching mechanism of mybatis

    Time:2022-4-18

    This article will talk about the caching mechanism of mybatis, which is based on version 3.4.6. Knowledge points What is caching Mybatis cache Cache implementation mechanism What is caching I believe anyone who has studied programming knows the concept of cache, which is mainly aimed at access efficiency. If our program consumes resources from disk […]

  • Introduction to Python decorator

    Time:2022-4-16

    Universal formula of decorator When Xiaobai is learning decorators, he will encounter some places that he doesn’t understand or know very well. This is because you directly roll the decorators at the beginning. So how can you understand and understand the decorators?Therefore, before learning decorators, you must understand the nesting and closure of functions. Next, […]

  • Decorator decoration mode

    Time:2022-4-8

    >>Return to c# common design patterns 1. Introduction 2. Examples 2.1. Examples in the framework 1. Introduction definition Dynamically add some subsidiary responsibilities to an object. The natural understanding of decoration is based on the original items(Do not change original items), add something else to make it more satisfying. Class diagram 2. Examples using System; […]

  • Introduction to Python simulation test

    Time:2022-4-8

    How to test without patience Often, the software we write interacts directly with what we call “dirty” services. Generally speaking, services are very important to our applications. The interaction between them is designed by us, but it will bring undesirable side effects – functions that we don’t want when we test ourselves.For example, maybe we […]

  • Come and see the summary of good articles on laravel design pattern!

    Time:2022-3-11

    Many design patterns are used in laravel, and many new PHP features are used to implement these design patterns. Learning these design patterns can help us: Learn the new features of PHP, know how to use the new features and write fresh and refined code Learn the design patterns of real examples and think about […]

  • Simple example code 2

    Time:2022-3-4

    1、 Closure def outer(): x = 1 def inner(): print(x) Return inner # returns the body of the function without parentheses f = outer() F () # call 2、 Function decorator def decorate(func): def f(): Print (“the original function starts”) func() Print (“the original function is over”) Return f # returns the body of the […]

  • ”Control inversion IOC, dependency injection Di “how to achieve?

    Time:2022-2-25

    Newton once said: if I see farther than others, it is because I stand on the shoulders of giants. Reading the source code of the high-quality framework library can learn a lot. What’s more, it has created better ones based on this, which is roughly the case. Midwayjs has forgotten how to know it. The […]

  • Application of decorator mode in laravel

    Time:2022-2-20

    What is decorator mode Decorator mode allows you to add new functionality to an existing object without changing its structure. Simple code implementation: interface Decorate { function getInfo(); } /** * Class DecoateA *Initialize a decoration object */ class DecoateA implements Decorate{ /** *Implementation interface */ public function getInfo() { echo __CLASS__.PHP_EOL; } } /** […]

  • Decorator pattern of PHP design pattern

    Time:2022-2-18

    When the factory model is over, let’s study some other models. I wonder if you guys have tried women’s clothes? It is said that there are a lot of women’s clothing bosses and programmers. In fact, today’s decorator model is very similar to makeup. I believe that if there is a program yuan mm, I […]

  • Decoration mode (learning notes)

    Time:2022-2-7

    1. Intention Dynamically add some additional responsibilities to an object. In terms of adding functions, the decorator pattern is more flexible than generating subclasses 2. Motivation In some cases, we may “use inheritance excessively to extend the function of objects”. Inheritance is static,You cannot change the behavior of an existing object at run time,Only objects […]