Serial: Object-oriented sunflower treasure: thought, skill and practice (37)-design mode: Swiss Army knife or hammer?

Source: Internet
Author: User

"Design mode" This word almost become synonymous with software design, many people very naïve thought mastered the design model to master the software design , but in fact, if only to grasp the design mode, the software design door has not touched!


========================================================


Talk about the design pattern, it is almost nobody knows, no one does not know, the famous " GOF "(Chinese some translated as" Gang of Four ") the work of the world, really" never know GOF , learn to design also in vain! "

However, the design pattern is really the "Swiss Army Knife" of software design, cutting, sawing, cutting, drilling everything proficient?

There are a lot of friends who have read design patterns, but there is little estimate of the subtitle of the design pattern, and this subtitle is the key to avoiding misunderstanding design patterns. The subtitle of design mode is: The basis of reusable object-oriented software!

Do not underestimate this short sentence, if you did not look at this sentence, or just swept away and did not carefully understand, then you probably think that the design pattern is a "Swiss Army Knife", can solve all the design problems, and in fact, " design pattern is just a hammer ", there is a proverb called " If you have a hammer in your hand, then all the problems become nails "If you take the design pattern this hammer goes out and knocks, either the thing is knocked down or it doesn't work.

Why is the design pattern just a hammer? We still look at the subtitle. The subtitle of design pattern reveals the two main constraints of the design pattern:

1) The design pattern solves the problem of "reusable" design;

2) The field of design pattern application is "object oriented";

I believe that through my reminder, we are basically able to understand why "design mode is just a hammer":

1) design mode can only solve the "reusable" design problems , other such as performance design, reliability design, security design, serviceability design, etc. are not designed to solve the pattern;

2) Design patterns are only applied in object-oriented languages , and are not very useful if they are non-object-oriented languages. Of course, you can use the C language in the design mode, but after all, to toss a lot, use it is not so heart with the hand.

So, when you come across a problem and think about design patterns, be sure to pay attention to " design pattern is just a hammer ", don't take this hammer everywhere to knock!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.