Strategic Patterns for Design Patterns

Policy Mode Behavioral patterns In Strategy Pattern, the behavior of a class or its algorithm can be changed at run time. In policy mode, we create an object representing various policies and a context object whose behavior changes as the policy object changes. The policy object changes the execution algorithm of the context object. introduce I ...

Posted by unknownsheep on Sun, 22 May 2022 23:14:27 +0300

Java thread pool Architecture Principle and source code analysis (ThreadPoolExecutor)

In the previous article on JUC, we mentioned the creation of thread pool exectors. In the article:< JUC series of java - external Tools >There are detailed descriptions in the first part of the, please refer to;   In fact, the article explains the external use mode, but does not say how the internal implementation is implemented. I ...

Posted by herschen on Sun, 22 May 2022 22:45:09 +0300

[Design Pattern]Template Method Pattern

Template method pattern Introduction The template method pattern is a simple and commonly used design pattern. It is a code reuse technology based on class inheritance. Its structure only has the inheritance relationship between the base class and the derived class. A template method is a concrete method that gives a top-level logical flow fra ...

Posted by JonathanS on Sun, 22 May 2022 20:11:21 +0300

Template mode of design mode

Project source code: CSDN : http://jacob.org.cn Nuwa's mistake The factory model tells the story of Nuwa making people. People are created and the world is lively, but when she looks down, they are all the same type. They lack love, hatred, joys, sorrows and other emotions. Human life is peaceful and light. Nu Wa suddenly patted her head and f ...

Posted by imartin on Sun, 22 May 2022 15:51:08 +0300

Command mode of JavaScript Design Mode [command decoupling]

Before explaining the command mode, let's first understand a command mode scenario in life: Scenario 1: Hospital treatment and prescription: When you go to the hospital to see a doctor because of kidney deficiency, the doctor comes to the conclusion after some operation: you need to take a course of treatment [Xia Sangju] and [Xiaochaihu] (the ...

Posted by AlGale on Sun, 22 May 2022 14:36:53 +0300

Adapter pattern -- Design Pattern

As the name suggests, adapters have to adapt to different current configurations and solve compatibility problems. Our life is full of all kinds of adapters. The modem used for Internet access is a kind of digital to analog conversion adapter, commonly known as "cat", but now it is all optical cat, that is, the mutual conversion of op ...

Posted by villas on Sun, 22 May 2022 13:37:03 +0300

Understand the decorator design pattern from the root with pictures and texts

decorative pattern Also known as: decorator pattern, decorator pattern, Wrapper, Decorator intention The "Decorator Pattern" is a structural design pattern that allows you to bind new behavior to an original object by placing the object in a special wrapper object that contains the behavior. decorative design pattern question ...

Posted by Rayne on Sun, 22 May 2022 04:08:07 +0300

The project has created hundreds of threads. How do you optimize it?

preface Have you ever encountered this situation when you open the Profiler tool of Android studio Hundreds of threads?? Why is the name 12345? Why are they all in sleep or wait but not destroyed? In fact, when the scale of a project becomes larger and larger, with the change of developers, the non-standard old code and the introduction of more ...

Posted by uberpolak on Sat, 21 May 2022 18:01:49 +0300

23 design patterns of Java -- II. Singleton pattern

The source code is in mine github and gitee Get in introduce Singleton Pattern is one of the simplest design patterns in Java. This type of design pattern is a creation pattern, which provides the best way to create objects. This pattern involves a single class that is responsible for creating its own objects while ensuring that only a single o ...

Posted by Kunax on Sat, 21 May 2022 05:12:22 +0300

The template method pattern shows a programmer's day

Please indicate the source of Reprint: http://blog.csdn.net/lmj623565791/article/details/26276093 Continue design pattern ~ template method pattern For the old routine, first look at the definition: it defines the skeleton of an algorithm and delays some steps to subclasses. The template method enables subclasses to redefine the steps of the al ...

Posted by christine75 on Fri, 20 May 2022 15:37:30 +0300