A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
However, what is the significance of learning and using the design model for development? The design pattern is like a martial artist and a martial artist for a developer. I used to be a martial arts fan. Jin Yong and Gu Long basically read all the martial arts novels. I am ashamed to say that I have almost achieved this in the four years of college.
In martial arts novels, there are a lot of martial arts secrets, especially Jin Yong's novels. There are numerous names, such as the title of the Dragon's 18 ops, jiuyin Zhenjing, and Qian Kun's great migration. We know that there are also many design patterns, such as the factory model, strategy model, and observer model. These two things seem different, but as long as we analyze them carefully, it is not difficult to find that they are similar. We know that the purpose of development is very simple, that is, to complete the project and satisfy the customer. The purpose of martial arts is also very simple, that is, to defeat the enemy. Of course, if you only want to strengthen your health and fitness, you don't need any secret. You can simply go home and run, or do two push-ups.
Anyone who has read martial arts novels knows that once a martial artist has mastered a secret and fights with others, it is really amazing. Mei chaofeng in "shooting" is, she only learned a few tricks, but she still doesn't have full control of them, because she is different from the full-hearted cow, she will cultivate internal strength, and she doesn't know what "five-hearted up ". However, she almost tried to do whatever she wanted. In the face of Fu Sha tongtian that group of people playing can be described as a waste of water. In the same way, when we develop, if we use a suitable design model to meet some special requirements of our customers, we will get twice the result with half the effort. For example, the customer sometimes asks that the SQL Server database should be used in the early stage of the project we have done, but the database can be upgraded to Oracle at a certain time in the future. At this time, I am afraid everyone knows that we can use the factory mode. By writing different parameters in the configuration file, we can use different databases without having to modify anyCode.
Of course, a factory model cannot solve all the problems in the software. Does that mean that all the problems can be solved by mastering all the design patterns? No! Just like the secret of martial arts, even if you do not have the foundation of martial arts, it is impossible to defeat all enemies. Although Mei chaofeng stole the secret, he was also bullied everywhere in the rivers and lakes. Not only is there a lot of people she can't beat, but she is also very easy to get angry because she can't beat the nose internal power. The same is the design pattern. If you do not have a thorough understanding, it is easy to learn and misuse by mistake. I have had this experience and used the singleton mode in the database connection class. I think I am pretty smart, and the results are not the same. The specific reason is that the singleton mode does not need to be used in the database connection class. If you are interested, you can study it yourself. I will not talk about it here.
Learning the secret of martial arts sometimes requires a hard price. For example, in the shooting sculpture, Ouyang crazy has been focusing on the 9 Yin Zhenjing and suffering from humiliation for many years; another example is Yue weiqun in "Xiao aojiang Lake". To avoid evil swords, he can be a full-fledged pseudo-gentleman or even his own palace. Of course it is not so difficult to learn well and make good use of the design model, but it also requires a lot of time and effort. First, you must have a certain programming Foundation,Programming LanguageSome basic knowledge should be mastered. Such as regression, abstract classes, and inheritance. Just as you must first practice basic skills before you practice martial arts, the basic skills are not solid, and it is difficult to practice them. Wei xiaobao in the "Deer Ding Kee" is a typical example. The secret books are learned a lot, but they will be used but not used. It will be nothing else if you fight to escape. Of course, it is not here to criticize the "Lord Wei", because although people do not do martial arts, they are still well mixed and are absolutely successful and do not need to criticize.
It is not difficult to learn the secret of martial arts. As long as you are patient, intelligent, and stupid, you can also learn. The clever Huang Rong can quickly learn how to beat a dog, and the stupid Guo Jing can also become the "hands-on Mutual combat" invented by Zhou botong ". It is not difficult for people with certain programming basics to master various design patterns. Books on design patterns are also full of resources. If you go to a bookstore or find one on the internet, it will take about two days. In fact, everything is the same. No matter how we study programming or design patterns, as long as Guo Jing learns to fall into the palm of the dragon, he can practice for three days with a simple trick of "The Dragon has no regrets, even if you are stupid, there is nothing difficult to learn. As Chairman Mao taught us, there is no difficulty in the world, as long as you are willing to climb. Of course, when we study hard, we also need to pay attention to skills and methods. When learning every design pattern, it is best to find an instance for reference so that you can understand it more quickly. For example, in the adapter mode, the power used in our notebook is a typical adapter instance, and one thing that converts power is an adapter. In the development process, the adapter mode is to encapsulate a class to implement functions that are not previously available or to expand the original functions.
The secret of martial arts does not mean that martial arts are powerful. In the "tianlong eight steps", Wang yuhan understands many of the secrets, but she has no hands to help. However, an expert not only has rich combat experience, but also understands how to integrate and use it flexibly. After reading the "Passionate swordsman" written by Gu Long, you will know that although the highest realm of martial arts can do whatever you want, you can see the moves, and finally you can win without any moves. The vulnerability can be found only when the other party makes a move. We know that if we can only rely on some fixed tactics to win, we can only stay in the low-level stage. The same is true for the design model. Even if all the design models are backed up, if they cannot be integrated and used flexibly, I am afraid the software cannot be designed. You can only design a specific mode to solve the actual problem based on your needs. With specific problems, we have research directions. Another point is that the design model should not be rigid. Although there are many existing design models, there are as many as 23 classic models. However, in the case of actual problems, it is often difficult to find the existing mode to solve the problem. Just like the highest realm of Taiji, only when you forget the ready-made moves can you see the flow of water and see it.
As for how to design a model to solve practical problems, it may be vague to explain how to integrate, use flexibly, and analyze specific situations. This is not a clear answer. The highest level of the design model is the same as that of martial arts. There is no fixed pattern. You can find a specific solution to specific problems. But one thing we should understand is that when we design software, we must abide by some basic principles of software design, such as the dimit law, Rishi replacement, and dependency reversal. I believe that the ultimate goal of these principles is nothing more than high cohesion and low coupling.
In the end, many technical experts are easily referred to as heroes. In fact, the technical heroes are the same as those of martial arts heroes, it must also have a high character. The same is true in terms of technology. Only by virtue of both ability and political integrity can we be truly heroes. It is the hero of the nation for the people.
Then again, the secret of martial arts is just something in the novel and belongs to the artistic category. In real life, at least not completely exists. Here we combine the two to make everyone better learn and use the design model, I hope this article will help people who are interested in the design pattern to go faster and farther.
Start building with 50+ products and up to 12 months usage for Elastic Compute Service