views:

427

answers:

3

Can you point me to a reference of design patterns in Standard C (C89 or C99)? (Not C#, not C++.)

+7  A: 

G'day,

Take a look at Axel-Tobias Schreiner's ebook Object-Oriented Programming with ANSI-C. You'll have to handroll some aspects of some patterns but you'll be able to implement many of the simpler GoF ones.

HTH

cheers,

Rob Wells
+5  A: 

Design patterns should be language agnostic - unfortunately most of them assume an object oriented environment.

http://stackoverflow.com/questions/674722/struggling-with-c-coming-from-object-oriented-land

Nick
Design patterns are sold as something that should be language agnostic. As universally applicable models, when in fact they are conventions spawned by the programming models that are in vogue. They're perfectly fine for what they are, but they've been sold as something they're not.
Michiel Buddingh'
+1  A: 

Following from Nick's answer, I suggest that you learn how to implement cplusplus-like things using C (e.g., a C struct with a pointer to a table of function pointers, emulates a C++ class with virtual functions), which means understanding how C++ is implemented by the compiler. Once you've done this then you'll be able to read design patterns for C++ and implement them using C.

ChrisW
It will be fun for a while, but maintaining such a beast is a PITA.
quant_dev