The problem with the Object Oriented Programing

General discussion for topics related to the FreeBASIC project or its community.
Munair
Posts: 1286
Joined: Oct 19, 2017 15:00
Location: Netherlands
Contact:

Re: The problem with the Object Oriented Programing

Post by Munair »

marcov wrote:
Munair wrote:
"to claim that those who criticize OOP do so because they're all pro functional programming or that they just dislike OOP.
I didn't say that. I said people worrying excessively over state are probably from the functional side of things. I never hear a procedural or oop programmer worry about such things.
'Probably' is an assumption, just as you assumed a functional counter solution:
marcov wrote:We can also turn this around; show me the big functional projects that do it the "right" way.
I'm very much an imperative and procedural programmer and I see the problems and difficulties with both OOP and FP. Perhaps the "right" way lies somewhere in the middle; procedural programming with some structuring by means of TYPE/STRUCT, combined with more flexibility around functions such as support for anonymous functions.
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: The problem with the Object Oriented Programing

Post by paul doe »

caseih wrote:...
Shoe-horning everything into a particular paradigm leads to tears. Not everything needs to be made into an opaque object. Maybe some day we'll figure out how to engineer software.
And herein lies the actual solution for the 'problem' of OOP. Pure procedural, pure OOP, pure functional et al will never be able to solve every problem, simply because some problems are better expressed in certain ways that some paradigm can't easily accomodate.

The best tool for us would be the ability to choose the right solution for the right problem. And to determine that requires skill and experience. So, fear not any paradigm: expose yourself to them, as much as you can; the more the merrier. Assess their strenghts and weaknesses. Learn how to use them until they become second nature. Just by doing that you'll be leagues ahead of most fellow coders out there.
RockTheSchock
Posts: 252
Joined: Mar 12, 2006 16:25

Re: The problem with the Object Oriented Programing

Post by RockTheSchock »

paul doe wrote: Jan 13, 2022 1:00 The best tool for us would be the ability to choose the right solution for the right problem. And to determine that requires skill and experience. So, fear not any paradigm: expose yourself to them, as much as you can; the more the merrier. Assess their strenghts and weaknesses.
I agree with you. Some ideas explained:
https://www.youtube.com/watch?v=wyABTfR9UTU
aurelVZAB
Posts: 666
Joined: Jul 02, 2008 14:55
Contact:

Re: The problem with the Object Oriented Programing

Post by aurelVZAB »

there is simple solution
dont use OOP if you dont need it
Mihail_B
Posts: 273
Joined: Jan 29, 2008 11:20
Location: Romania
Contact:

Re: The problem with the Object Oriented Programing

Post by Mihail_B »

(First hello again, long time no replies, but I read this forum on weekly basis)
So, here's a real life story ...
First time you make a program that reads from a file CSV rows and you apply some rules to some columns and write the new stuff to a new file.
The 2nd time the boss tells you need to be able to read from XLS files too; so you make some changes, abstract the CSV reader. Maybe you get away with an IF THEN ELSE ENDIF.
The 3rd time the boss gives you 100mil row CSV and it task a million seconds to parse it. The boss wants this faster. You optimize the code, read in memory buffer, process batches, etc.
The 4th time the boss wants you to process the same amount but now from a new format, binary data. He also tells you he plans for you to introduce several other tens of file formats just to be able to read native data from each customer ...
So you start refactoring your code. You group code and start making code work with reusable and configurable elements.

The 10th time boss whats a new app that does the same as above but instead he wants you to plot a graphic, draw statistics.
The 11th time boss whats same stuff but this time wants to filter some data and send it securely (ssl) to server.

So you start wondering why didn't you just group everything from the very beginning so that you can reuse code.

Oh wait, wait ... now boss wants an all time up service that does this live, no restarts.
So your one-thread up crashes due to memory leaks and segmentation faults due to overwriting data unintentionally.
So you start wondering why didn't you wrote constructors and destructors to safely deallocate data ...
After valgrind-ing and valgrind-ing and doing tests with millions of rows you get the job done...
Great ... you have a running service that reads from disk and can answer to network requests etc.

It's gets even more complicated ... so you start learning templates for classes and methods so that you can you various structures with same class.
You refactor like there is no tomorrow.
But you've learned your lesson ... you'll never write without making classes ... reusable, independent, testable, etc ...
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: The problem with the Object Oriented Programing

Post by caseih »

Indeed sometimes a little structure and abstraction goes a long ways. Just be aware there are other forms of abstraction besides using OOP (as you describe it). And it's always easier in hindsight to come up with the ideal structure and paradigm. The world is full of Java programmers who do program everything in classes (because they have to), and I can assure you there's just as much rewriting and re-implementation that goes on as the demands and features requested ever change by management. And in the end, it's often more important to get it done than to get it done perfectly right. As they say, perfect is the enemy of good. Personally I tend to hung up on details and spent ages trying to conceive of the perfect structure, paradigm, and algorithms for my projects, and get nothing done! My successful projects are ones where I put that all aside and just try hacking something together. Sometimes I do end up re-writing and re-factoring a few times. Other times, I don't. It's not perfect or even always easily extensible, but it works.

I've personally done projects very similar to what you describe (CSV reading, later XLS spreadsheet, then different kinds of data analysis), and I've successfully done it without much OOP or re-writing. Granted I wasn't using FB and I had other syntactic features of a language available.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: The problem with the Object Oriented Programing

Post by Axle »

So as suggested I had a read through this thread and it felt a bit like a million other OOP vs Imperative debates that I have read.

"There is nothing either good or bad but thinking makes it so" - Shakespeare

Each methodology has it's place as well as it's advantages and disadvantages, but neither can really be described as right or wrong, good or bad.

I remember reading somewhere that Imperative programming makes it easy to shoot yourself in the foot, OOP makes it a lot harder to shoot your self in the foot, but when you do it blows your whole leg off.

Personally I prefer to to punish myself with the speed and power of Imperative Procedural Orientation as some of us just prefer the journey and the pain of writing boiler plate code. That being said I still write everything in a modular way, so it's not difficult to swap out a function to an improved version

Next Cats vs Dogs - What is your preferred...
Just kidding lol

regards
Axle

P.S. I had to come back and add a note/question about a lot of the talk on OOP C++ and some context to raylib.

I see a lot of people talking about C++ OOP in the context of FB. Now I don't yet fully understand the pre-compiler and internals of FB at this time, but it is compiling on GCC and MinWG library. C-99 has no native OOP and no ability to compile C++, so I don't understand why all of the C++ talk. ?

Also I have seen many people referring to raylib in the context of C++. Again, raylib being a C-99 library, I can't fit anything C++ into the context of either raylib or FB. ?
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: The problem with the Object Oriented Programing

Post by caseih »

Axle wrote: Jun 30, 2022 12:55Personally I prefer to to punish myself with the speed and power of Imperative Procedural Orientation as some of us just prefer the journey and the pain of writing boiler plate code.
Java has ruined two generations of programmers into thinking they know what OOP is. I use OOP all the time and I never write boiler plate code. And as far as paradigms go, I can't think of the last time I didn't use procedural, OOP, and functional programming all at the same time. Granted I'm generally not working with Java's brand of OOP.
Axle
Posts: 67
Joined: May 31, 2022 6:49
Location: Australia

Re: The problem with the Object Oriented Programing

Post by Axle »

caseih wrote: Jun 30, 2022 16:56 Java has ruined two generations of programmers into thinking they know what OOP is. I use OOP all the time and I never write boiler plate code. And as far as paradigms go, I can't think of the last time I didn't use procedural, OOP, and functional programming all at the same time. Granted I'm generally not working with Java's brand of OOP.
A. I don't code in Java.
B. I prefer C.
C. I prefer Imperative Procedural Orientation. Doesn't mean I don't use OOP or even Functional Programming. It's just a preference :)
D. Does it really matter? If you don't like the language or the way it is constructed don't use it lol There is like ~300 programming languages to choose from :)

Axle
Post Reply