You think the delegation model is mysterious, but you use it every day

This article is excerpted from "design patterns should be learned this way"1. Use delegation mode to simulate task allocation scenariosWe use code to simulate the business scenario where the boss assigns tasks to employees.First, create the IEmployee employee interface. public interface IEmployee { void doing(String task); } Creat ...

Added by siefkencp on Tue, 09 Nov 2021 08:09:48 +0200

Composite mode

In real life, there are many "part-whole" relationships, such as departments and colleges in universities, departments and subsidiaries in headquarters, books and bags in study supplies, clothes and wardrobes in household appliances, pots and pans in kitchens, etc. This is also true in software development, such as files and folders i ...

Added by seidel on Sun, 07 Nov 2021 18:29:59 +0200

Proxy pattern of design pattern

There are six principles and twenty-three design patterns in the design pattern. The six principles are: single responsibility principle, opening and closing principle, Richter substitution principle, dependency inversion principle, interface isolation principle and Dimitri principle. Twenty three design patterns: Singleton pattern, Builder pat ...

Added by MrKaraokeSteve on Sat, 06 Nov 2021 15:25:09 +0200

Efficient access to third-party login and easy to expand method

This article is excerpted from "design patterns should be learned this way" 1. Use class adapter to reconstruct the free adaptation of third-party login We use the adaptation pattern to implement an actual business scenario and solve practical problems. A little older partner must have experienced this process. The old systems dev ...

Added by corylulu on Wed, 03 Nov 2021 08:23:03 +0200

Interviewer: Can you write a publishing subscription model with JS?

What is a publish subscription model? Can you do this by handwriting? Is it different from the observer mode?... 1 Scene introduction Let's start with a scenario like this: Suppose you have a social platform with a V called Nami Nami is brilliant and versatile. Currently she has two skills: she can write songs and take videos. She will pub ...

Added by NSH on Tue, 02 Nov 2021 20:45:53 +0200

Design pattern - strategy pattern

Application scenario: now the supermarket needs a set of supermarket cashier system. We need to make a set of cashier system. The demand will be very simple. When we think about it, it's just a matter of several text boxes. Enter the unit price and quantity, and then calculate it. However, if supermarkets launch discount activities in the later ...

Added by Master_Phantom on Tue, 02 Nov 2021 16:06:49 +0200

Interviewer: why do you customize the wrap of view_ Will content fail?

preface Interviewer: why wrap in custom View_ Will content fail? To answer this question, we need to understand the past and present lives drawn by view When is the view drawn? In which life cycle of the Activity is the view drawn? After onResume Get to know viewrootimpl We know that the onResume method is actually just a callback method ...

Added by ecco on Tue, 02 Nov 2021 11:36:55 +0200

13 Demeter's Law -- object oriented design principle

Opening and closing,Richter substitution,Dependency inversion,Single responsibility,Interface isolation,Dimitt,Synthetic multiplexing In the previous sections, the opening and closing principle, Richter substitution principle, dependency inversion principle, single responsibility principle and interface isolation principle in object-oriented d ...

Added by Kaizard on Tue, 02 Nov 2021 05:33:37 +0200

Practical application of policy pattern in business

Strategy pattern structure diagram The policy mode is mainly composed of the above three identities. Here we will not introduce the basic knowledge of the policy mode. By default, everyone has a basic understanding of the policy mode. Business requirements There is a demand for burying point reporting of advertising click data. The reported bu ...

Added by damdempsel on Mon, 01 Nov 2021 05:42:25 +0200

Creative design pattern experiment

Write in front Copy an assignment on the Internet, but there's no money! I have a fart money. I'm so angry that I wrote it directly. Share it here for reference (you can copy it, but you have to copy it when you know it). You can reprint it without signing my name, but you need to state that it is not original. This is a series of homework, so ...

Added by NeilB on Fri, 29 Oct 2021 14:30:01 +0300