Markus Schnell
Markus Schnell

Reputation: 1095

Reference to Design Patterns in ANSI C?

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

Upvotes: 10

Views: 5780

Answers (4)

thinwybk
thinwybk

Reputation: 4743

If you need information about real-time embedded C design patterns i can recommend the two books

  • "Real-Time Design Patterns: Robust Scalable Architecture for Real-Time Systems" (Douglass, Bruce Powel | Elsevier | 1th Edition | 2002) and
  • "Design Patterns for Embedded Systems in C: An Embedded Software Engineering Toolkit" (Douglass, Bruce Powel | Elsevier | 1th Edition | 2011)

Some of the higher-level patterns depend on an "emulation" of object-oriented features like mentioned before. The patterns are described very well (UML diagrams, examples). I like the discussions of the "forces" (What has to be considered?) which influence the context after applying the patterns.

Upvotes: 1

Rob Wells
Rob Wells

Reputation: 37159

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.

Upvotes: 14

ChrisW
ChrisW

Reputation: 56123

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.

Upvotes: 2

Nick Van Brunt
Nick Van Brunt

Reputation: 15484

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

Struggling with C coming from Object Oriented land?

Upvotes: 7

Related Questions