Allowing inheritance with Records?
Remi Forax
forax at univ-mlv.fr
Fri Dec 29 14:05:45 UTC 2023
> From: "Vikram Bakshi" <vab2048 at gmail.com>
> To: amber-dev at openjdk.java.net
> Sent: Thursday, December 28, 2023 3:59:10 PM
> Subject: Allowing inheritance with Records?
> Hello,
> Is the decision to not allow inheritance for records set in stone? Or will this
> be opened up and explored in the future?
> One of the goals of records (from Brian Goetz Devoxx talk) is to "model data as
> data", and allowing inheritance would offer a powerful way of modelling data.
I almost spill my tea :)
Inheritance is about sharing behaviors, so the data behaviors should not change too much. But business requirement, business data/computation changes are frequent, so using inheritance is a kind of an an anti-pattern for data.
It's far far easier to use records, empty interfaces and pattern matching (switch on types) when you want to define data and their business rules than tryig to use inheritance for a case it will not work well.
> Right now we have to write interfaces for fields which are shared/static methods
> for shared behaviour/copying and pasting - which I do not think is ideal.
> Regards,
> Vikram
regards,
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20231229/08467789/attachment-0001.htm>
More information about the amber-dev
mailing list