This always made OOP so frustrating to me. You have to go look in tons of places and build a mental model of all of them to have an idea what code does.
This always made OOP so frustrating to me. You have to go look in tons of places and build a mental model of all of them to have an idea what code does.
The difference between FP/OOP and AOP is that with FP/OOP you know where to look. References outside the file you are currently looking at are usually declared at the top of the file. While with AOP there are no references in the files that are affected by AOP code.
With a more functional style you often rather make consumers to pass a function with behavior modifying code, the upside is that the specialization is given from the call-site and that the callee can is more explicit about passing out things without needing to care about the specialization context, and often it's easy to compose specializations in this way in one place.
OOP emphasizes encapsulation, decomposition, and dependency injection more aggressively than other paradigms. See SOLID. [1] While not necessarily bad, it does result in more "pieces."
Java -- arguably holding the #1 spot for OOP popularity -- requires that each (public) class be in its own file. This results in a lot of files.
OT: I remember someone noting that he tried to have modular code with as little functionality per module but reached a point where searching for things took writing it.
I sometimes ponder if it would be possible to create a DSL for every tiny niche part of each application. It would likewise depend on how awesome the documentation is and if you can even find it.
I think LLM's could make both ideas viable. One would be able to find anything and figure out how it works.
Could have a committee that judges how reusable your language extensions are and possibly grades you as a programmer with hints on how to improve.
Writing the coffee machine DSL should give you bragging rights.
A bit like languages nowadays accumulate new features.
In an ideal world one would write functions, the repetition of those would be documented and spawn language features, repetition and usage of those would spawn features in the lower language in which the language is implemented which in turn would spawn machine instructions. All using real data in stead of a cultivated hunch or popularity contest. How many installs, how often does that part of the code run, how many cycles can we save globally.
(But then you had to keep the diagramms in sync with the code)
The objects in OO really don’t need to have anything to do with the outside world.
Projects where the majority of the code sits in a handful of giant bloated objects passing messages to each other tends to be quite flexible in practice. This works because rather than treating objects as consistent bundles of data and code throughout the program it’s often useful to think in terms of different contexts and then pass messages between those contexts. The advantage being you have fewer side effects to worry about when editing code, which is really the entire point of OO.
I'd take that a step farther - if they do, that's probably a sign that you're taking things too literally. They probably _shouldn't_ have anything to do with the outside world. I die a little inside every time somebody introduces inheritance with that stupid Dog extends Animal example.
I've seen developers claiming that "encapsulation" is just about "having getters/setters and private fields". But those getter/setters never get any custom implementation, they're just accessors for other classes.
It's not really OOP anymore at this point. Classes are just records, or depositories of procedural subroutines.
In the name of Single Responsibility Principle, there's a lot of breaking up classes in a way that forces encapsulation to be broken. A class doesn't always have to expose all its data!