Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
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
Posted
Updated 14-May-10 1:57am
v2

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

[Edited to modify the obviously daft assertion that you can implement most patterns in C as C++. Doh.]
 
Share this answer
 
v2
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.
:-)
 
Share this answer
 
Comments
Emilio Garavaglia 31-May-10 2:43am    
Why?? The Win32 API are object oriented, and fully written in plain C!
CPallini 31-May-10 4:35am    
I cannot spot the 3 pillars of OOP in the Win32 API. :-)
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900