Feedback on Records in JavaFX
Ty Young
youngty1997 at gmail.com
Sun Apr 26 22:28:10 UTC 2020
On 4/25/20 9:34 PM, Nir Lisker wrote:
> ### Conclusions
> There are not that many places where records can be used, though for these
> specific use cases they fit well (nominal tuples); many of them are inner
> classes. From the above list, some stray a lot from the idea of records
> (4), some not so much (1, 3).
> I would cautiously say that the design is too restrictive, especially when
> it comes to internal helper state (5, 6). I would think that, while
> a record component is given to the constructor and exposed through the
> accessor, other internal (final) fields that help with implementations
> would be useful. This reminds me of interfaces - while their public methods
> serve as contract, private methods were made valid just to help with
> internal implementation, and they are invisible to the contract.
> With regards to accessor visibility (1, 2), I know that there was (or is) a
> discussion about allowing to reduce their visibility to that of the class
> (not sure about the constructor). Sometimes there is no need for them at
> all.
>
> I hope that this concept of records can be expanded, either to specialized
> types for other similar use cases, or with changes from other features that
> work well with records, as records alone don't hit enough targets in my
> opinion. I intent to continue to update this branch as I work with whatever
> use cases I find, so by the time JavaFX can use records we would have a
> good starting point.
Yep, same conclusion I've had converting classes to records in an
*actual*, *realistic* project. There are plenty of cases where Records
could be used in theory but due to how restrictive they are it isn't
possible.
As it stands, they are going to fade into obscurity along with other
rarely used features like loop labels. Once people realize just how
restrictive they are, interest in them seems to die nearly instantly...
at least the vast majority of discussion online seems to that I've seen.
That said, it seems like whenever the discussion of Records come up it
seems like the question of "can this help me reduce boilerplate?" rather
than "can this help me represent nominal tuples?"comes up way more often
so maybe there isn't actually much interest in super strict nominal
tuples to begin with.
>
> Best,
> Nir
>
> [1] https://github.com/nlisker/jfx/tree/Records
More information about the amber-dev
mailing list