The design mode is just a hammer!
When talking about the design model, it was almost unknown and unknown. The famous "gof" (some Chinese translated as "the four-person gang") was an amazing work. It was really "no one knows about gof in my life, and I have never learned how to design it!"
However, the design model is really the "Swiss Army Knife" of software design. Are you proficient in cutting, cutting, sawing, and drilling?
There are a lot of people who have read the design patterns, but few people have really noticed the design patterns. This subtitle is the key to avoiding misunderstanding of the design patterns. The subtitle of design patterns is:The basis of reusable Object-Oriented Software!
Do not underestimate this short sentence. If you have not read this sentence, or you have never carefully understood it, you may think that the design model is a Swiss Army knife ", can solve all the design problems, but in fact"The design pattern is just a hammerThere is a saying: "If you have a hammer in your hand, all the problems will turn into nails, it either gets knocked out or does not work.
Why is the design pattern just a hammer? We can see from the subtitle. The subtitle of design patterns reveals two main constraints of design patterns:
1) the design model solves the following problems:Reusable"Design Issues;
2) the application field of the design model is"Object-oriented";
I believe that after my reminder, we can basically understand why the "design pattern is just a hammer:
1) the design model can only solve the "Reusable" design problems. Other problems, such as performance design, reliability design, security design, and service design, cannot be solved by the design model;
2) The design pattern is only used in object-oriented languages. If it is not an object-oriented language, it will not work very well. Of course, you can use the design pattern in the C language, but after all, it will take a lot of effort and it will not be so easy to use.
Therefore, when you encounter a problem and think about the design model, you must pay attention to "the design model is just a hammer". Don't hold this hammer everywhere!