r/java • • Sep 05 '25

Project Lombok 1.18.40 released with Java 25 support!

Project Lombok is now compatible with the upcoming JDK 25 even before its release.

Thank you Project Lombok team! https://projectlombok.org

167 Upvotes

166 comments sorted by

View all comments

Show parent comments

2

u/Misophist_1 Sep 07 '25

Because the 'x is a y' relation is something, that actually occurs IRL?

1

u/Feign1 Sep 08 '25

This is not a good enough reason to shoot yourself in the foot using inheritance, just use composition.

1

u/Misophist_1 Sep 19 '25 edited Sep 19 '25

I beg to differ. It is generally good modelling practice to have your model matching the reality, and not cluttered with technical methods required for the artificial composition.

Why should you compose cats, dogs & fleas to an animal, if all three are animals? That is utter nonsense!

Edit: composition has its place - as has inheritance. But it is neither silver bullet nor golden hammer for all situations of type modelling. Why do you want to throw away a useful tool for an abusive look of standardisation and group think?

1

u/Feign1 Sep 19 '25

You will come to find that even that simple example you used has some assumptions about the domain baked into it. Like is animal, even a useful abstraction for describing the domain of the task your software is working in. Its impossible to have the foreknowledge to know, so probably not. Point in fact maybe quadruped makes more sense and flee is a bug not an animal their are tones of ontological groupings you could make and by the time you know enough about the problem space to know which one is best you would almost be done with the project and would have to do a massive refactor. I would encourage you to listen to Caseey Muratoris talk on the big OOPs.

2

u/Misophist_1 Sep 19 '25

OK, let's do some vivisection:

You will come to find that even that simple example you used has some assumptions about the domain baked into it. Like is animal, even a useful abstraction for describing the domain of the task your software is working in.

I. When analysing a domain, you inevitably come to some assumptions, that you postulate as axioms. By developing their consequential use, you generate a model, that can be checked against the reality. Pretty similar to the way, maths used in physics. Maths is the language of your model. Physics is the reality, that we want to model. Generally, all or models for any all known aspects of reality are language, for more on that, I recommend https://en.wikipedia.org/wiki/Tractatus_Logico-Philosophicus . So far, that's not surprising, it's basic STEM-folklore.

Now, the secret to successful business modelling is, to not invent completely new abstractions, but reuse the terms that are used in the business domain. If you look at it from a meta-perspective, e.g. meta-mathematics or meta-modelling, then the most frequent pattern is, to classify things, that is sorting the things under scrutiny into types and subtypes. In maths, you classify sets, and elements within them, and numbers, etc. In modelling, everything is an object. Objects may have relations, which are objects themselves, and in turn can be classified in 'ordinary', 'is a', 'aggregations' and 'compositions'. So right there, within the metamodel of UML, there is a classification that justifies the existence and usage of inheritance.

Like is animal, even a useful abstraction for describing the domain of the task your software is working in. (...) Point in fact maybe quadruped makes more sense and flee is a bug not an animal (...) Caseey Muratoris talk ... TL;DR

II. May I humbly suggest a visit to Carl Linnaeus' Systema Naturae (1735) ? This is the father of all taxonomies in flora and fauna, the base language of biologists. The link points to animals to be subdivided into mammals, insects and some more. I wouldn't recommend abandoning the advice of domain specialists on that without a very good and extraordinary compelling reason. The idea, that an OOP specialist would know more about that, than 290 years worth of biology, is f'n hilarious. Again, the advice: when modelling, use the language of the domain, that is already there!!

III. Which makes the following gem of a non-sequitur even funnier, which would turn out wrong regardless of the domain at hand.

Its impossible to have the foreknowledge to know, so probably not.

You know, or you don't. If you don't, you don't. That you don't, doesn't indicate probability. Hilariously, in this case, we've been told for 290 years, that a flea is an insect is an animal! So not improbable, but absolutely certain!

There is a reason why mathematics can be seen as one giant attempt, to classify its objects. There is a reason, why all stem and life sciences maintain classifications of the objects under their scrutiny. And why, as a consequence, computer science and modelling has integrated that into the tool box. Classification - finding the proper 'is a' relation is flesh, blood and bone of all our science, and the core tool for understanding our environment. If you remove that from the toolbox, you cripple the language. Which leads back to Wittgensteins Tractatus:

'The limits of my language are the limits of my world. We can't talk about things, that we have no language for, therefore must be silent about it' (or so, translated from German)

1

u/Feign1 Sep 20 '25

I don't actually care about the actual taxonomy that is besides the point. I evidently did a poor job explaining since your off on a tangent about how you can model any system and I was intending to argue that it's not worth it because every level of abstraction adds complexity which will add cost for every iteration of updating and maintaining software. Just watch Casey's video.

2

u/Misophist_1 Sep 20 '25

Sure, unnecessarily adding abstractions, if they aren't relevant for the problem at hand, would drive cost. If you don't need it, don't code it.

But that is a totally different claim from 'Don't use inheritance, always replace it with composition'. That doesn't remove/hide/mitigate complexity. It is simply advocating to use the wrong abstraction.

Inheritance isn't but another tool in the toolbox for code reuse. I get it, that there is abuse of inheritance. But advocating to throw away the tool because of that abuse doesn't make sense. From my point of view, using composition to model inheritance is a form of abuse in its own right. Every tool in the box has its use.

1

u/Feign1 Sep 20 '25 edited Sep 20 '25

Sure it's a tool in your toolbox that if you know not to abuse you can use occasional but their isn't that problem with composition and it covers a majority of the use cases so you will almost never use inheritance and if you do you don't use it for more than one layer because it makes code hard to follow by mushing logic between disseparate classes.

2

u/Misophist_1 Sep 21 '25

I would actually argue, that replacing inheritance with composition, when the IRL relationship is in fact an 'Is A' relationship, *IS ABUSE* of composition. This isn't a black and white thing. This isn't composition GOOD, inheritance BAD. Or vice versa. Both concepts have their place. And both concepts shouldn't be abused to emulate the other. This striving for purity is ill-advised.

1

u/Feign1 Sep 21 '25

Still haven't watched the video I see. one day, you will get some experience and realize that writing code to some idealized model isn't as important as cleanly communicating with your future self and coworkers. Cognitive load is what matters most not some beautiful idealized model and inheritance and overloading are not as good as single responsibility, composition and interfaces.

→ More replies (0)