Let me first say that I've got a fair amount of experience in both C and C++. However, I'm starting a new project in C and I've been working in object-oriented languages for so long (C# and C++) that I am having trouble coming up with an effective way to encapsulate functionality in a procedural language. My first thought was to simply fall back on my OO knowledge and structure it something like:
struct Foo
{
int x;
char *y;
};
struct Foo *new_Foo()
{
return (struct Foo *)malloc(sizeof(struct Foo));
}
void Foo_member_function(struct Foo *foo, int z)
{
foo->x = z;
}
But that just seems tedious and contrary to the spirit of C. Not to mention that it is a poor-man's OO.
This program is ultimately going to get fairly sizable, so starting from a good design organization is critical. I imagine with the years of development in C, certain design patterns have developed in how to best structure the code for maintainability. Much like functional programming, I'm hoping that procedural programming has a paradigm that is clean and fairly readable.
Pointers to relevant articles and books are acceptable as well.