I'm very new to programing
is objective oriented programming writing programs that consist of many different "modules" that can be swapped, replaced and reused in other programs?
did I get it right?
>>58298080
no way jose
that's functional programming
Not even close
>>58298080
That's part of it, but that's been normal in ordinary imperative languages for a while, for example C libraries. What really sets OOP apart is that it defines this concept of "classes", which don't only contain data, but also functions that control the behavior of objects. It doesn't give you the ability to do anything you couldn't do before (since all programming languages are Turing-complete), but it does streamline some common usage patterns.
For example, in C your code might look something likesoldier bob, george;
soldier_init(&bob);
soldier_init(&george);
soldier_attack(&bob, &george);
The equivalent code in C++ would besoldier bob, george;
bob.attack(george);
Here, rather than having to define "soldier_attack" as a globally-accessible function that takes two pointers to soldier-objects, you're declaring it as PART of the soldier-class, meaning you could (for example) have a similarly named function as part of another class, and the compiler would be able to tell them apart by looking at the class-type of the parent object. Additionally, there is no need for explicit calls to initialization functions, since C++ and Java have the notion of a "constructor" which is a function called AUTOMATICALLY whenever an object is created.
>>58298145
OP here
your explanation is the best I've read so far on the internet. thanks for that
>>58298145
yeah that sounds about right
one thing i never understood when i was learning programming is why no one could explain this properly
>durr its programming but with objects
>>58298080
OOP is encapsulation of data and behavior inside an """""""object""""""". These objects communicate with each other by sending messages to each other in various ways (depends on the language). It is a programming style that is supposed to handle state complexity in simulation programs such as vidya games, physics simulations, chemistry simulations etc etc. OOP languages: Java, C#, C++
For handling state complexity in non simulation programs, we have functional programming. Functional programming is prettymuch just math on steroids, it enforces referential transparency and limits side effects in order to reduce complexity (which works much better than just stuffing everything into an """"""""object"""""""). Functional languages: Haskell, Ocaml, Scala, F#
Procedural programming is like the default style of programming, it takes things one step at a time and generally involves manually dealing with state complexity (which every programmer should know how to do before moving on to higher abstractions like OOP). Procedural language: C
>>58298080
>you will never nurse her back to health
Well, shes actually dead