We find that design patterns are very popular in the Java community, but in the C + + community It is not so much attention, or even a bit of exclusion, what is the cause of this difference?
(1) C + + memory needs to be managed, so some patterns are not so convenient to use in C + +, but Java does not care about memory, so the use of design patterns in Java has a natural advantage. With shared_ptr, weak_ptr, unique_ptr and so on to join the c++11, I believe this aspect will be improved.
(2) in Java's class library system, many designs are based on design patterns themselves, so when calling the Java class Library, you unknowingly use design patterns, which results in design patterns being used when designing your own interfaces.
(3) C + + is generally used to solve some relatively low-level problems, so when using C + +, we are more concerned about how to implement a feature, but Java with its rich class library, the implementation of feature is often not a problem, so they have more focus on design.
(4) The design mode is usually indirect layer, will cause the loss of performance, and C + + application occasions tend to emphasize performance. For this problem, if your program is more focused on performance (such as the kernel), you should not introduce too many layers of indirection, but if your program is more focused on extensibility and maintainability, you should consider design patterns.
(5) Many programmers in the C + + community are coming from C and even the assembly, so these people are more accustomed to the process-oriented design approach, that is, using C + + is just to encapsulate some simple classes, not in design mode.
(6) C + + supports a variety of programming models, including process-oriented, object-oriented, object-based, generic programming, design patterns are primarily object-oriented, and Java only supports object-oriented development.
(7) design Patterns in large-scale C + + open source projects are still relatively more, such as Network library ACE, interface Library qt, game engine orge, Irrlicht, etc.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Why is design mode not popular in the C + + community without the Java community?