F
Francis Moreau
Hello,
I have to use a library which has an API that I find a bit weird for
the C language, so I'd like to get some feedbacks to know if it's a
good API design for C or it's just a bad practice.
Basically this API is an object oriented API.
To allocate an object I have to use for example:
o = alloc_object();
Once I have a reference on that object, I have directly access to its
internal data structure. So to call its methods I can do this:
o->m1();
And this is what I find weird. I would do instead:
m1(o);
which is more natural when doing C (probably because all very used
lib, like the libc, pthread... don't do this) and has the advantage to
not expose the internal data of 'o'.
Could anybody tell me if there is one good reason to do so ?
Thanks
I have to use a library which has an API that I find a bit weird for
the C language, so I'd like to get some feedbacks to know if it's a
good API design for C or it's just a bad practice.
Basically this API is an object oriented API.
To allocate an object I have to use for example:
o = alloc_object();
Once I have a reference on that object, I have directly access to its
internal data structure. So to call its methods I can do this:
o->m1();
And this is what I find weird. I would do instead:
m1(o);
which is more natural when doing C (probably because all very used
lib, like the libc, pthread... don't do this) and has the advantage to
not expose the internal data of 'o'.
Could anybody tell me if there is one good reason to do so ?
Thanks