Simple Object Oriented Programming (OOP) in C

preview_player
Показать описание
This video will cover a simple example of doing object oriented programming with C.

The purpose of this video is that we will be using designs like this in some of the low level projects and I want you to be familiar with the concepts rather than me explaining each time it comes up.

This video will also help you with linux kernel development as this type of pattern is often used in the linux kernel code base.

Code:

Subreddit:
Рекомендации по теме
Комментарии
Автор

I love your work. It would be interesting to contrast this abstraction with a C++ equivalent class + methods like a side by side comparison. Have you had a look at the CMSIS-driver implementation? this reminds me of it.

DavidCabanis
Автор

Greate work, I love it. What about the second part of this presentation? About inheritance and polymorphism?

graflaszlo
Автор

WOW! Amazing video! Thank you! Can you recommend a good book about it? I mean... I don't want basic books about C programming. Instead, I'm looking for books with practical experiences and solutions, like you showed in this video.

fuscatube
Автор

What GNU+Linux distribution and Desktop environment are you using?

rilwansmith
Автор

Placing function pointers inside structs so that you can make them "look like" methods and use the dot or the pointer operator so that it (again) "looks like" C++ type object operation etc. is a really stupid idea. OOP is a paradigm and a paradigm can be implemented in any language. There is no need to make your OO code in one language look like some other language. Standard C has some OO code, just look at the FILE type and the functions that operate on it!

rajdivecha
Автор

I usually like what u do but your creation of the logger/file_logger is IMO really bad .. especially as you mention being a java ptogrammer: your abstraction is truly bad, and you know it if you have written any amount of code (which I believe you have). The point of an abstraction is to flatten differences between concepts to their shared notion... NOT AT ALL what u do here for the construction part (no issue with the logger itself).... looked again... that init() is to me a really poor abstraction... I mean.. seriously bad.. does not stop anyone from from passing a console logger to the file logger init... I know that creating realistic examples is 5 more minutes of thinking... but I someone decides to teach something, then why not do it seriously??? The point of an API is to make the right things easier and the wrong ones HARD... this does none of it. So YES for the concept (used everywhere), but NO for how poorly you teach it.

Alperic