C语言中的设计模式 [英] Design patterns in C

查看:113
本文介绍了C语言中的设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

C(不是C ++)中的设计模式是什么.

我一直在尝试在网上查找,但搜索结果只能得到C ++设计模式.

有人可以指导我在哪里获得一些有关C语言中设计模式的学习材料/参考,以及一些示例.

或者,如果您对此有任何想法,请进行解释.

谢谢
Vicky

Hello,

What are the design patterns in C (not C++).

I have been trying to find on the web but getting only C++ design patterns as result of search.

Could anybody guide me where can I get any study material/reference for design patterns in C with some examples.

Or if you have some idea about it please explain.

Thanks
Vicky

推荐答案

设计模式(除少数例外)与语言无关.您可以像使用C ++一样轻松地在C中(从概念上)实现它们.例如,OpenSSL是一个完全用C语言编写的库,它使用了工厂,代理,策略以及第一本设计模式书中的其他一些模式.

您将无法使用特定于语言的模式.它们并没有很多,但是浮现在脑海的是计数指针,它是C ++特有的,在任何其他上下文中都是没有意义的.

干杯,



.
Design Patterns (with a few exceptions) are language neutral. You can implement them in C (conceptually) just as easily as C++. For example OpenSSL which is a library completely written in C uses factory, proxy, strategy and a few other patterns from the first design patterns book.

What you won''t be able to do is use language specific patterns. There aren''t that many of them but one that springs to mind is counted pointer which is so C++ specific it''s meaningless in any other context.

Cheers,

Ash


对于设计模式",我们通常打算使用面向对象的设计模式",即在很大程度上依赖于该语言的面向对象功能的设计模式.您会发现这种含义与C编程语言不太匹配.
:-)
With ''design patterns'' we usually intend ''Object Oriented Design Patterns'', i.e. design patterns that heavily rely on the Object Oriented features of the language. You see such meaning doesn''t fit well with the C programming language.
:-)


我希望大多数设计模式都需要创建伪类才能使其在C中工作.但是,更大的问题是,为什么要知道?现在似乎有一股潮流,他们似乎认为知道一个或两个模式名称将使他们的代码变得更好,并且除非您了解何时以及如何使用模式,否则确实不太可能实现.
I expect that most design patterns would require to yout create pseudo classes to make them work in C. However, a bigger question is, why do you want to know ? There seems to be a tidal wave of people right now who seem to think that knowing a pattern name or two will make their code better, and unless you understand when and how to use patterns, it''s really very unlikely to be true.


这篇关于C语言中的设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆