develop best practice (oop style) program in c .. with few questions in mind ..
How do you achieve good data abstraction .. (is it just hidden local variables or somthing like containers) ..
How to split functionalities into modules .. (are modules just c files or can be many c files = 1 module)
Do you achieve oop by doing structs passed to unique name functions as c doesnt have classes like c++
Are design patterns applicable in c ?
----------
Im not looking for answers here but any one suggest me a good book that answer these ?
You can find some examples of implementing abstract data types in C https://www.embedded.com/abstract-types-using-c/
in C most people define a single file as a object/object-like modules are groups of such files that can be classified to be part of the category. And you don't do C++ like OOP in C... that's kind of the point of C.
And here is some short explanation of mimicking classes and inheritance in Glib https://en.wikibooks.org/wiki/C_Programming/GObject
I prefer to not muddy the water with GObjects and Glib in general... There aren't a contemporary of usual modern C development.
Right, my mistake to ask about oop in c .. i just ment (best practice) ..
Glib and Gtk+ are modern C libraries that are actively developed and pretty widely used I don't know what you mean by "not contemporary"
Thanks for sharing, i dont understand the last prograph (what's missing) .. if initialize buffer function is missing then just implement it in the buffer.h instead of doing it in main? ..
They aren't usually used in C projects. Only 1 out of tens of my C projects have them as a indirect dependency...
Instead of accessing tail and head i ment in main
They are talking about lack of constructors and destructors in C.
You usually don't try to emulate inheritance either. The question was about techniques analogues to OOP in C.
Обсуждают сегодня