Dear reader, if you think it worth spreading, spread it around, and the more people you are with us, the easier it is to be liberated. If you have other comments, please also criticize and correct. Thank you ~
Before we begin, we should recognize this concept:
The essence of the program is to get the output data structure from the input data structure. 1
In order to keep it short and easy to understand, it’s good to recognize this sentence as roughly understood.
The cause of
Programs are one of the most complex projects ever constructed by humans, requiring the collaboration of many people. This leads to an interesting revelation: at first we thought that code was written for machines to execute, but in fact it was written for other people to read and understand, and for other people to understand! At this point, we finally understand and ask everyone to do it well. Because it reduces communication costs.
Identify communication bottlenecks
Aside from actual coding time, most of the time is spent communicating. Because you always have to connect with other people. A good example of this is the front end and the back end because there is a clear line that can be clearly delineated and connected. However, for each end of the internal team members, because there is no clear boundaries can be divided, so it is generally divided according to the functional module, which is also good, it seems to work well.
Over time, the system gets bigger and more complex. In Code Review, I found that when all modules were built up to form a whole, I was still confused. Every module and docking method has been carefully designed, why is it still so? Because although each module is developed independently, it always ends up being thrown together in a logical way, and complexity suddenly rises again.
It seems that there is no good communication, this way of communication and docking is not very smooth.
Causes the nature of complexity
Divide, then communicate docking. There is nothing wrong with the process. Collaborative communication on the front and back ends works well. Even if the system is complex and it’s hard to figure out how the modules interconnect, it’s always easy to figure out how the front end and back end interconnect. It’s weird. Is there always interface documentation on the front and back ends, but not between internal modules? It’s a facade, and even with documentation, it’s not much better.
This is because of the way the internal modules are organized. The docking between the internal modules is characterized by a mixture of modules arranged to work together in a logical process, need to be careful. Coupling magically happens again, and they become complex blobs again.
We often make the mistake of thinking that the reason systems are complex is because of coupling. Coupling is not the main cause of complexity. Because the front and back ends always need to be coupled together, it can still be kept simple.
The real complexity is the process, and always has been.
The utility of submodule is to hide too much logical process, but the module splicing still needs to follow the logic process ring by ring to occlude the whole program system. Like a lot of complicated gears. This also proves the true phenomenon of modules being happy when divided, but having headaches and nausea when put together. We do this process over and over again.
The solution
Or from the front and back end of the communication to think, why does this work so well? This is because they do not communicate with each other using procedures, but using data structures. The front and back ends always communicate through data structures, which directly avoids the need to organize complex logical processes. Without introducing intrinsically complex processes, the original data structure is kept simple and clear. This just goes back to verify the fact that the front and back end communicate harmoniously.
Therefore, the internal module division development, the last part to provide docking should be the data structure, not the process.
Data structured programming
Data structuring should always be a fundamental guiding principle. Again, recognize the concept at the beginning of the article and see the benefits. We can do a good job of assembling a program using only the parts of the data structure that are essential to the nature of the program.
Through data structures, we have a good idea of how modules are composed and the valid data parts, even if we don’t understand the internal processes. We were concerned with the structure of the program, not the implementation.
So, the element of a wrapper module is to define the input data structure and the output data structure. Everything is structured. This will reshape your thinking habits, free your mind, and make your code clear.
The advantage of changing habits of mind is that it is also easier to explore the implementation process.
- Based on the defined target data structure, detailed procedures are then organized to populate the data. This is a counter-proof method, first have a clear overall cognition in mind, and then verify step by step, which is easy to understand.
- Procedural programming, by contrast, uses a solution approach that requires step by step, step by step, careful, intense, and painstaking work.
And then and then, now when we communicate with each other, it’s very simple to say: you give me this data structure, AND I’ll give you the target data you need, rather than telling people that you have to call this, and then this, and then this…
Communication becomes easier. The whole world brightened up.
The liberation of thinking
If you think that the world of programming is chaotic, then we can re-understand it by thinking about data structuring. We hope this new thinking will help you unshackle yourself and gain some relief.
Rainforest invitation 🌲
All plant trees, all enjoy shade; It takes ten years to grow trees, but a hundred to cultivate people. A tree is difficult to shade, difficult to cover the sand, together into a forest can benefit others benefit yourself.
Planting trees is a great pleasure.
Rainforest: https://github.com/rainforesters/rainforest-js start easy experience data structured programming. Let’s plant trees 🌲🌲🌲
How to become a Rainforest man fastest
Like, spread, contribute source code, ideas, writing, preaching, as long as the participation, are rain forest people.
- Not exactly rigorous, but easy to understand and remember. ↩