Let's look at the element pattern

 

Foreword:
 
     It was the first time I participated in the book trial reading activity. After reading the trial reading chapters of "Element Mode" several times, I decided to write this article as a guide reading article, which is convenient for interested friends to study together.
 
Introduction :
 
     When we see the title of the book, the first thing we will ask is, what kind of book is this?
     This is a book that introduces design patterns.
     Then we will be curious. We have heard of the singleton pattern, the decorator pattern, and the factory pattern. So what is the element pattern?
 
concept:
 
     Elemental DesignPattern ( EDP for short ) is a set of basic programming ideas, and the core concept is a set of basic object-oriented concepts.
 
     I'll go, it's more puzzling to say than not to say. Can't you come up with some easy-to-understand explanations?

     In fact, it can be properly understood by applying the translator's metaphor (participating in the translator's preface)-combined with the design patterns we have known before (23 classic design patterns in "Design Patterns", this book is referred to as GoF), GoF is equivalent to compounds such as sulfuric acid, salt, and glucose, and they have specific functions in specific scenarios. In this paper, EDP refers to chemical elements such as hydrogen, oxygen, sulfur, and carbon with finer particle sizes than GoF.

     To put it simply, EDP is a general term for some design patterns that are simpler than GoP, as many as 16 are given in the text.

     How did these 16 patterns come about? Do they have any special connection?

           In the author's words: The element pattern is built on the basis of the design space. The main dimensions of the design space are objects, fields, methods, and types. They are divided into several distinguishable intervals according to their states, forming a hyperspace coordinate system. Two-dimensional and three-dimensional projections of this coordinate system are of course visualized, and in two-dimensional or three-dimensional space, several adjacent squares are formed. Each square has a clear physical spatial orientation and represents a specific element.
 
     Yes, it is to establish objects, methods, fields, and types into a four-dimensional coordinate system, forming 2^4=16 independent spaces, each space representing an element pattern.
 
     Let's take a brief look at the icons below.


 
          In order to facilitate everyone's understanding, the author first draws the objects and methods as a two-dimensional coordinate. Introduce 4 classic EDP concepts. There are two sections of similarity and no acquaintance on the coordinates. For the convenience of understanding, we can first understand them as "same" and "different".
 
[1] Recursion : The same object calls the same method, that is, recursion, which is well known.  
[2] Delegate : A method of an object calls another method of another object, that is, a delegate.  
[3] Redirection : Different objects call with a method, which is redirection.  
[4] Aggregation : Different methods in the same object are aggregated. 
 
          It looks like it's awesome. But what is their point? In what scenarios should we use them? What are their benefits? What other similar concepts are there?
 
          Mendeleev was once questioned or laughed at when he first invented the periodic table, and the impact of the discovery of the periodic table on the entire chemical world is self-evident. So, are the elemental patterns we are now studying so far-reaching? I look forward to the answers below, and I hope to solve the series of questions mentioned above.
 
 
 
 
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326564403&siteId=291194637