Feedback on Records in JavaFX
Nir Lisker
nlisker at gmail.com
Sun May 10 14:54:05 UTC 2020
>
> In your example, what about just doing
> record PopupFeatures(boolean hasToolbar, boolean hasMenubar)
> IMO this is also a lot clearer than doing something like
> record PopupFeatures(boolean toolbar, boolean menubar)
As I wrote, this is what I did because it's an easy case. For the general
case, it requires some thought. There is no obvious solution, but the point
is that if it was not considered, perhaps it should, because booleans are
an exception: while we write field names such as "maximized" and getters as
"isMaximized", we will need to adjust the field name to accommodate the
accessor. In all other cases, the field name, "numberOfHats" does *not*
need to change to "getNumberOfHats" to fit the accessor, instead, we adjust
the method call sites. Maybe it's fine, maybe it isn't.
On Sun, May 10, 2020 at 5:12 PM Kasper Nielsen <kasperni at gmail.com> wrote:
> >
> > Also, did you consider the point I made about accessor names of boolean
> > fields?
>
> Even if having a special case for boolean component types was a good idea.
> I don't really see how this could work? Is it isX() or hasX()?
> What if I have a
> record Stuff(boolean isCertified, boolean hasPassed) {}
> Would you get isIsCertified() and hasIsPassed().
>
> In your example, what about just doing
> record PopupFeatures(boolean hasToolbar, boolean hasMenubar)
> IMO this is also a lot clearer than doing something like
> record PopupFeatures(boolean toolbar, boolean menubar)
>
> /Kasper
>
More information about the amber-dev
mailing list