> -----Original Message-----
> From: Development <development-bounces+alexander.blasche=qt.io@qt-
> project.org> On Behalf Of Simon Hausmann


> > I don't consider the longer names detrimental for writability and usability.
> Writability is easily solved with code completion and readability is actually 
> better
> because the type adds additional context info. To cite an example from Shawn's
> patch:
> >
> > QQuickPointerDevice::Finger
> > QQuickPointerDevice::Mouse
> >
> > is far less descriptive than (and not compliant to current naming 
> > convention)
> >
> > QQuickPointerDevice::PointerType::Finger
> > QQuickPointerDevice::DeviceType::Mouse.
> >
> > The uninitiated reader of the code cannot see the additional type context
> when reading code and therefore someone might interpret Finger as a device
> type too. That's exactly what the existing unscoped enum policy tries to fix.
> Scoped enums provide this feature out of the box. Another example of a good
> naming policy (IMO) is QAbstractSocket (never mind the technical limitations).
> Here we could shorten the enum names using scoped enums:
> >
> > QAbstractSocket::SocketError::ConnectionRefusedError ->
> QAbstractSocket::SocketError::ConnectionRefused (or even
> QAbstractSocket::Error::ConnectionRefused)
> >
> > Name clash prevention was only ever secondary to readability.
> >
> We don't need scoped enums to improve readability though, that doesn't
> seem like an argument. To take the finger/mouse example, we would use
> 
>      QQuickPointerDevice::FingerPointer
> 
> or
> 
>      QQuickPointerDevice::PointerType_Finger
> 
> and you get exactly the same benefit, no?

I don't see how your two options above are any different(better?) readability 
wise than QQuickPointerDevice::PointerType::Finger.

I believe I mentioned earlier that in light of Qt 6 it might actually make 
sense to rename some enum type names too which means
QQuickPointerDevice::Pointer::Finger is possible and we can remove some of the 
redundancy between enum type name and enum value name.

Sure, we can get away with the old style of naming but when you consider that 
the length of the string is extremely close to being the same and gain type 
safety, why would we not use them? Of course, if you purposely don't want to 
type safety traditional enums are still the way to go.

My five cents..
--
Alex
 

_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to