[Development] Naming convention for (scoped) enums

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Mon Aug 13 18:12:16 CEST 2018


Il 13/08/2018 16:40, Tor Arne Vestbø ha scritto:
> Or:
> 
>    if (event->device()->pointerType() != QQuickPointerDevice::Finger
> 
> Gives me all the info I need, and having to type or read this instead is worse in my opinion:

This is actually against the old "non-enum class" coding standards: one 
must repeat the enumeration name in the enumerators. Then, the 
difference is between something like

QQuickPointerDevice::FingerPointerType (?)

and

QQuickPointerDevice::PointerType::Finger

So quite minor, all in all...


> 
>    if (event->device()->pointerType() != QQuickPointerDevice::PointerType::Finger &&
> 
> I think we should revisit this policy, and only use it when there’s actually a clash.

Which is always "too late" if we're talking about public APIs, as 
they're set in stone.

By the way, the C++ community has already recognized the excessive 
verbosity of enum classes, and there are proposals such as

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1099r0.html

that would drastically simplify the syntax. In the meanwhile, I would 
not work around it -- we need *some* enum scoping anyhow, and enum 
classes are the simplest way possible to not forget about it.

My 2 c,

-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20180813/d10ae7c6/attachment.bin>


More information about the Development mailing list