Create mode - singleton mode
catalogue
Characteristics of creative mode
Create pattern classification
Singleton Pattern
Single case introduction
Code demonstration
① Hungry Han formula (static constant)
② Hungry Chinese (static code block)
③ Lazy (thread unsafe)
④ Lazy (thread safety, synchronization method)
⑤ Lazy (thread safe, synchronous code block)
⑥ Double ...
Added by lasith on Fri, 10 Dec 2021 16:12:29 +0200
CGLIB Dynamic Proxy
Summary
CGLIB is a powerful and high performance code generation library. It is widely used in AOP frameworks (Spring, dynaop) to provide methods for intercepting operations. Hibernate, as a popular ORM framework, also uses CGLIB to proxy one-side (many-to-one and one-to-one) associations (another mechanism for delayed collection extractio ...
Added by LiLaaron on Thu, 09 Dec 2021 19:54:43 +0200
State mode of design mode (29)
1, APP activity lottery question
Please write a program to complete the APP lottery. The specific requirements are as follows:
If you want to deduct 50 points from users every time you participate in this activity, the winning probability is 10%;The number of prizes is fixed, and you can't draw ...
Added by Miko on Thu, 09 Dec 2021 03:48:22 +0200
Observer mode of design mode (25)
1, Foreword
In the real world, many objects do not exist independently, and the behavior change of one object may lead to the behavior change of one or more other objects. For example, when the price of a commodity rises, some businesses will be happy and consumers will be sad; Also, when we drive to the intersecti ...
Added by Hokus on Tue, 07 Dec 2021 12:23:42 +0200
Common front-end JavaScript encapsulation methods
1. Enter a value and return its data type
function type(para) {
return Object.prototype.toString.call(para)
}
Copy code
2. Array de duplication
function unique1(arr) {
return [...new Set(arr)]
}
function unique2(arr) {
var obj = {};
return arr.filter(ele => {
if (!obj[ele]) {
ob ...
Added by spiritssight on Fri, 03 Dec 2021 12:44:39 +0200
Factory Method Mode: Delay to subclass to select implementation
Framework and Design Patterns What is the framework: Framework is semi-finished software that can complete certain functions.
What does a framework do: it can accomplish certain functions and speed up application development; Provides a sophisticated program architecture.
The relationship between framework and application: who does a ...
Added by thatsme on Wed, 01 Dec 2021 21:33:04 +0200
PHP advanced feature - combination of Reflection and Factory design pattern [code example]
PHP advanced features - Reflection and the combination of factory design patterns [explained in combination with the example of laravel admin code]
Use reflection to realize the production of factory mode without creating specific factory classes
Article address http://janrs.com/?p=833 Reprint without authorization of the author
Please indic ...
Added by mabans on Wed, 01 Dec 2021 14:38:58 +0200
Agent mode of design mode (20)
1, Foreword
In some cases, a customer does not want or cannot directly access an object. At this time, it needs to find an intermediary to help complete a task. This intermediary is the proxy object. For example, you don't have to go to the railway station to buy train tickets. You can buy them through 12306 websit ...
Added by jowatkins on Tue, 30 Nov 2021 14:26:36 +0200
[Java background development specification] - cycle complexity
preface
Most of those who do java development may have read Alibaba's Java background development manual, which contains some contents about Java background development specifications, basically covering some general and universal specifications, but most of them are concise. This paper will mainly use more cases to explain some specificat ...
Added by mwq27 on Mon, 29 Nov 2021 15:05:55 +0200
Design model of Shenkeng interview questions
This picture is from a unicorn company in Shenzhen
Design model of Shenkeng interview questions
When I see this topic, I think it's very interesting. Isn't it to remove if else if? Isn't this a typical strategy model? Of course, if else if cannot be completely eliminated by policy mode alone, and if can be eliminated by factory + policy mode ...
Added by superhaggis on Mon, 29 Nov 2021 05:33:46 +0200