It's a novice mistake to think the solution that wins out is the one with the most technical merit. Virtually nothing is truly meritocratic.
> It's natural to break large systems into component parts recursively, and to let components have their own state.
That's just modularity. Nearly every language has it, and OOP is merely one way to achieve it.
2. Where you do want them, like at coarser service boundaries, virtually all general purpose languages have modules of some sort.
2. If a module has state, is it not named with a noun, is not an object even if we try calling it an entity, an actor, or anything else?
But we're talking about OOP, which is characterized by specific logical properties surrounding modelling, encapsulation and extension, not about colloquial terms like "objects" that are referred to by nouns.
Conflating colloquial language with the programming language is one of many reasons why OOP seems seductive but is often misleading.
Also see Actor model or "out of the tarpit". Also Barbara Liskov "Programming with Abstract Data Type". Encapsulating state instead of behaviours is a mistake.
Grand parent is talking specifically about encapsulating state and not just behaviors.
Our Objects of today come straight from Simula.
Edit : and yes, there is a reason i said behaviour and not state. Objects are bad at encapsulating state, because you do not encapsulate state like that.
[1] And I could have tested this hypothesis by doing more background reading of the history, but I haven't.
Not sure it was the easiest way (see IMGUI), but I agree with you that some early UI frameworks took that approach and it was probably so much better than what came before it, that OOP is still riding that wave of enthusiasm.
The biggest lie OOP ever told was that breaking things into smaller components is specific to OOP
When you have a algorithm that goes Red-Hot, use Data-Orientated-Programming.
When you have lots of annonymous objects repeatetly passing through recombined pipelines, with minimal work, try a functional approach.
Try to see OOP not as the final stage of a masterpiece, rather as the launch-pad - and a first working version.
Also- what is the best approach, highly depends upon the goals of the project. Speed at all cost? Safety trumps all? Rapid development? Scale-ability?
PS: Regarding Object-Relational Databases- i found the true nest of snakes to be that for each object basically a small hand crafted version of git is needed to resolve the changes, once several applications start using the same DB. Not only that, but changes made, that relate to the changed data, needs to propagate- and can not do so only by simple trigger, but often by program-logic.
Sloppy work can lead to data fragments being part of two separate objects. What if two programs use one of two classes, but one resides within the other? Who has the right of update?
In addition ORM can hold duplicates of a Datum, and very soon, the urge will appear to replace every datafragment in your saved object with a pointer (key) to one, and only one instance of the real-world data piece.
TL,DR; This is one of the cases, where the pain comes not instantly, but after a while - and then never leaves. Get somebody who witnessed something like that blow up in another company to help you avoiding the worst.
A succinct definition of OOP would be nice to combat the misinformation you're complaining about.
The description of OOP provided in the Wikipedia article on programming paradigms [1] matches my current understanding of OOP.
> object-oriented which groups code together with the state the code modifies,
Maybe that's a little too succinct, because I think it's also worth noting how [2]
> In OOP, computer programs are designed by making them out of objects that interact with one another.
I certainly wouldn't consider coupling state and function completely orthogonal to OOP though. I doubt most other programmers would either.
I guess this might demonstrate the inertia of the so-called misinformation, but when the majority disagree with your definition of a term, you might want to step back and consider whether you're the one who's misinformed.
[1] https://en.m.wikipedia.org/wiki/Programming_paradigm
[2] https://en.m.wikipedia.org/wiki/Object-oriented_programming
The point I was making is that this is not an idea invented by, or reserved for, OOP.
If there's anything somewhat unique to OOP approach (both Smalltalk-like and Java-like), it's constructing the program as a graph of objects communicating with each other (be it via methods or messages).
> but when the majority disagree with your definition of a term, you might want to step back and consider whether you're the one who's misinformed.
Here's the thing: the majority of popular software engineering books were written during the OOP fad. They like to mix up OOP-specific things with universal techniques, making the latter look like a feature (or invention) of the former. A good cure for that is to grab something from pre-OOP era. Consider e.g. reading SICP (or watching SICP lectures) - it's the first book that made me realize just how much concepts popularly associated with OOP are paradigm-independent ways of structuring programs.
TL;DR: OOP did not invent abstraction, it only appropriated it.
We can make the same mistake of assuming a single monitor in Java or C, but both languages can also easily support multiple monitors ;)
I'm not sure where you got "the majority disagree with your definition of the term" when I didn't even attempt to define the term until this reply! Or why you key on the word "orthogonal" which is in the parent of my comment, and certainly is imprecise: A better description would be, OOP holds no exclusive claim to these ideas. We don't all despise OOP, but rather the false notion that it is a "silver bullet." I quite like well done OOP with expressive types.
I'd be irritated by you linking to Wikipedia articles for "Programming paradigm" and OOP except they're mobile links, which means you're getting all in a hissy on the go, and that's sorta cute.
A hissy is a good description of my last comment lol. I was getting pretty annoyed at people claiming that my understanding of OOP is wrong. I don't think OOP should be this incomprehensible thing.
I now understand that you just meant that not all encapsulation is OOP. I certainly agree there. Cheers.
My favorite question. Have a look at the sidebar in this link [1] for starters (by 'alternative' you didn't mean you expect me to advocate complete abolishment of OOP did you?). I'd say being familiar with at least 5-10 diverse paradigms from that list works wonders.
OOP is the most popular paradigm because it works the best for the greatest number of people and projects. It's natural to break large systems into component parts recursively, and to let components have their own state.
What alternative did you have in mind? Functional programming?