Click here to Skip to main content
14,303,925 members
Rate this:
Please Sign up or sign in to vote.
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
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.]
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
:-)
   
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. :-)
Rate this:
Please Sign up or sign in to vote.

Solution 3

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.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100