> So, how do you solve problems in C that users of other languages would do with classes? One very common pattern in C is just to do the same thing unofficially.
I started programming before OOP was widespread and I remember when I first had to use it. I put all my code into a single class which had a single instance.
However, I feel that it's the other way round now. People have programming with classes so ingrained that they can't break free even when working in non-OOP language like C. They simply emulate C++ in C.
The good old procedural style of programming is rarely seen nowadays.
I tried very hard to understand the draw that other people had to object-oriented programming, and it never took. It seems to me much leaner to use functions and associative arrays.
I spend a lot of time designing both. I try first of all to give functions good names: not too long yet telling. Then I fiddle with the arguments: their number, order, and names. And then for associative arrays I spend some time figuring out the best structure for them for easy use by everything else.
Maybe it's just because I write CRUD web apps. Most the processing is done in SQL. Then it's a matter of wrapping the resultant data in an HTML template. I write as little of my app in PHP as possible.
Of course with the HTML there is often JavaScript, another chance to get complicated. But I have tried the single-page application thing and found that the app was actually slower than my past apps, which were written in the ROCA style (http://roca-style.org/). So back to the ROCA style I went, where just using jQuery here and there doesn't get as unwieldy.
I started programming before OOP was widespread and I remember when I first had to use it. I put all my code into a single class which had a single instance.
However, I feel that it's the other way round now. People have programming with classes so ingrained that they can't break free even when working in non-OOP language like C. They simply emulate C++ in C.
The good old procedural style of programming is rarely seen nowadays.