开发者

Importance of a design pattern?

I am learning C++ I don't know much about this stuff except the fact that programming design pattern is neccesary when 开发者_如何学编程actually working in large projects.I hope its correct to some extent.

Is this common to all object oriented languages or do I need to look specifically into C++ design patterns.

Also How does it helps you.Is this realy important to learn as a C++ programmer.

Please suggest


Design patterns are often misunderstood. They are really a way for experienced users to have shorthand for describing common situations. You don't need to worry about them too much while you are learning C++.


You will hear discording opinions about design patterns, in the programming community at large.

In my opinion, it is sure that there are abstractions that patterns encapsulate that are really useful (factory, singleton, delegate, etc.). I use patterns a lot, but I myself am sometime puzzled by the apparent lack of depth or level of insight that you get by reading a pattern description. This is also in tune with the proliferation of design patterns that specialize for any kind of things.

When the design hey are useful, they are a very good means of communication and certainly they guide you through the process of designing or defining the architecture of your app. They are useful both for small project and for large ones, and they can be applied at different granularity levels.

Patters are a generic concept and all programming languages support them. Anyway, if you work in C++, a book focusing on it is best, because you will get the pattern adapted to the characteristics of the language.

In my opinion, the really fundamental book about design patterns are:

GoF, Design Patterns: Elements of Reusable Object-Oriented Software

VV.AA., Pattern-Oriented Software Architecture Volume 1: A System of Patterns

VV.AA., Pattern-Oriented Software Architecture Volume 2: Patterns for Concurrent and Networked Objects


Most of the design pattern are common to all object oriented languages.


For me design patterns are nothing but abstractions that shorten communication time between programmers. Instead of expressing a complex idea of how your program is designed, you can probably find a name of a pattern that describes the design of your program.

E.g. TPM says "We should use singleton here", and you interpret "We should use one instance of the class here".

Patterns are useful to learn, but one can program without knowing any patterns, yet using them a lot.


I see design patterns as collections of wisdom gained by experience, particularly addressing issues of flexibility and maintainability of code. For example: by using a facade we can change implementations without changing the code that uses the facade.

I think it's fair to say that all programming languages have wisdom to be captured, and design patterns of some sort will be useful. The C/C++/Java/C# heritage languages seem to offer a particularly rich seem to be mined for wisdom. C++ being quite gnarly really does benefit from some key design patterns.

Some folk see Design Patterns as a way of patching over language deficiencies, that would imply that "better" langauges might need fewer patterns. My feeling is that in all cases we have something to learn from experienced folks and Patterns help us codify their wisdom.

Edited to add: Interesting point made by Munish, it is best to do a little reinvention first? By writing some real code without explicit use of Patterns you may well start to feel dissatisfied with what you write ... when I change this, I need to change all that, is there a better way to write this? ... this may drive you to really need patterns and hence motivate your study.

If you have the luxury of time to learn this way then I think you'll probably benefit.


Design patterns are solutions to commonly occuring problems in Design phase of a project.These patterns provide the solutions which we can use independent of programming language.For e.g. there is Singleton design pattern which ensures that there is only one instance of a class.Now there are numerous occaions on which this may be required.You can use the solution of these pattern and use in your code.

They provide the re usability in Software development .Put simply, design patterns help a designer get a design right faster.

For more better understanding you could refer Design Patterns: Elements of Reusable Object-Oriented Software

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜