Skip to contentSkip to conversation

CODING_STYLE: Define how to handle acronyms in CamelCase

PATCH In review Alex Williamson 4 participants 6 messages Sep 24, 2012 – Sep 29, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CODING_STYLE: Define how to handle acronyms in CamelCase

When creating structure names in CamelCase, it's easy to have back-to-back capitals when using acronyms (ex. PCIINTxRoutingNotifier, QEMUSGList, VFIOINTx). In the worst case these can look like macros, but even adjoining a single, all-caps acronym makes it more difficult to interpret. For example, is PCIIntxRoutingNotifier sufficiently more clear? Mixing case, such as VFIOintx isn't truly CamelCase. Therefore let's abandon all-caps acronyms in CamelCase, resulting in PciIntxRoutingNotifier, QemuSgList, VfioIntx.

---

This is an attempt to formalize and get agreement on name changes suggested for the vfio-pci driver. VFIO is very prone to these naming problems. I don't expect to do any massive code churn to correct these, but I will update vfio-pci to whatever outcome we decide and at least we'll have a reference rather than per maintainer policy. Thanks,

Alex

 CODING_STYLE |    5 +++++
 1 file changed, 5 insertions(+)
CODING_STYLE +5 -0
index dcbce28..e45ed1a 100644
@@ -53,6 +53,11 @@ and is therefore likely to be changed.
 When wrapping standard library functions, use the prefix qemu_ to alert
 readers that they are seeing a wrapped version; otherwise avoid this prefix.
 
+When making use of acronyms in CamelCase only capitalize the first character
+of the acronym.  This promotes readability and clearly defines the start of
+each word or acronym.  For example, instead of PCIBAR, use PciBar.  In place
+of QEMUDMAList, use QemuDmaList.
+
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one
#1 lore raw
Quoted 11 lines · Alex Williamson

When creating structure names in CamelCase, it's easy to have back-to-back capitals when using acronyms (ex. PCIINTxRoutingNotifier, QEMUSGList, VFIOINTx). In the worst case these can look like macros, but even adjoining a single, all-caps acronym makes it more difficult to interpret. For example, is PCIIntxRoutingNotifier sufficiently more clear? Mixing case, such as VFIOintx isn't truly CamelCase. Therefore let's abandon all-caps acronyms in CamelCase, resulting in PciIntxRoutingNotifier, QemuSgList, VfioIntx.

I'm fine with these, but you should ask people like Blue Swirl who really care about coding style rules.

Quoted 30 lines

---

This is an attempt to formalize and get agreement on name changes suggested for the vfio-pci driver. VFIO is very prone to these naming problems. I don't expect to do any massive code churn to correct these, but I will update vfio-pci to whatever outcome we decide and at least we'll have a reference rather than per maintainer policy. Thanks,

Alex

 CODING_STYLE |    5 +++++
 1 file changed, 5 insertions(+)
CODING_STYLE +5 -0
index dcbce28..e45ed1a 100644
@@ -53,6 +53,11 @@ and is therefore likely to be changed.
 When wrapping standard library functions, use the prefix qemu_ to alert
 readers that they are seeing a wrapped version; otherwise avoid this prefix.
 
+When making use of acronyms in CamelCase only capitalize the first character
+of the acronym.  This promotes readability and clearly defines the start of
+each word or acronym.  For example, instead of PCIBAR, use PciBar.  In place
+of QEMUDMAList, use QemuDmaList.
+
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one
#2 lore raw
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Alex Williamson

When creating structure names in CamelCase, it's easy to have back-to-back capitals when using acronyms (ex. PCIINTxRoutingNotifier, QEMUSGList, VFIOINTx). In the worst case these can look like macros, but even adjoining a single, all-caps acronym makes it more difficult to interpret. For example, is PCIIntxRoutingNotifier sufficiently more clear? Mixing case, such as VFIOintx isn't truly CamelCase. Therefore let's abandon all-caps acronyms in CamelCase, resulting in PciIntxRoutingNotifier, QemuSgList, VfioIntx.

Quoted 5 lines
Quoted 2 lines

I'm fine with these, but you should ask people like Blue Swirl who really care about coding style rules.

Blue, any preference? Is this needed? Thanks,

Alex

Quoted 30 lines
Quoted 30 lines

---

This is an attempt to formalize and get agreement on name changes suggested for the vfio-pci driver. VFIO is very prone to these naming problems. I don't expect to do any massive code churn to correct these, but I will update vfio-pci to whatever outcome we decide and at least we'll have a reference rather than per maintainer policy. Thanks,

Alex

 CODING_STYLE |    5 +++++
 1 file changed, 5 insertions(+)
CODING_STYLE +5 -0
index dcbce28..e45ed1a 100644
@@ -53,6 +53,11 @@ and is therefore likely to be changed.
 When wrapping standard library functions, use the prefix qemu_ to alert
 readers that they are seeing a wrapped version; otherwise avoid this prefix.
 
+When making use of acronyms in CamelCase only capitalize the first character
+of the acronym.  This promotes readability and clearly defines the start of
+each word or acronym.  For example, instead of PCIBAR, use PciBar.  In place
+of QEMUDMAList, use QemuDmaList.
+
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one
#3 lore raw
In reply to Alex Williamson
Quoted 30 lines · Alex Williamson

When creating structure names in CamelCase, it's easy to have back-to-back capitals when using acronyms (ex. PCIINTxRoutingNotifier, QEMUSGList, VFIOINTx). In the worst case these can look like macros, but even adjoining a single, all-caps acronym makes it more difficult to interpret. For example, is PCIIntxRoutingNotifier sufficiently more clear? Mixing case, such as VFIOintx isn't truly CamelCase. Therefore let's abandon all-caps acronyms in CamelCase, resulting in PciIntxRoutingNotifier, QemuSgList, VfioIntx.

---

This is an attempt to formalize and get agreement on name changes suggested for the vfio-pci driver. VFIO is very prone to these naming problems. I don't expect to do any massive code churn to correct these, but I will update vfio-pci to whatever outcome we decide and at least we'll have a reference rather than per maintainer policy. Thanks,

Alex

 CODING_STYLE |    5 +++++
 1 file changed, 5 insertions(+)
CODING_STYLE +0 -0
index dcbce28..e45ed1a 100644

CODING_STYLE and is therefore likely to be changed. · line 60

Quoted 8 lines
CODING_STYLE +5 -0
@@ -53,6 +53,11 @@ and is therefore likely to be changed.
 When wrapping standard library functions, use the prefix qemu_ to alert
 readers that they are seeing a wrapped version; otherwise avoid this prefix.
 
+When making use of acronyms in CamelCase only capitalize the first character
+of the acronym.  This promotes readability and clearly defines the start of
+each word or acronym.  For example, instead of PCIBAR, use PciBar.  In place
+of QEMUDMAList, use QemuDmaList.
+

I'd prefer not to do this.

We do both within QEMU and I think that's fine. By choosing one vs. the other we just create a lot of friction because now people have to introduce structures that aren't consistent with the rest of the file.

Either is fine IMHO.

Regards,

Anthony Liguori

Quoted 3 lines
CODING_STYLE +0 -0
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one
#4 lore raw
Quoted 43 lines · Anthony Liguori
Quoted 30 lines · Alex Williamson

When creating structure names in CamelCase, it's easy to have back-to-back capitals when using acronyms (ex. PCIINTxRoutingNotifier, QEMUSGList, VFIOINTx). In the worst case these can look like macros, but even adjoining a single, all-caps acronym makes it more difficult to interpret. For example, is PCIIntxRoutingNotifier sufficiently more clear? Mixing case, such as VFIOintx isn't truly CamelCase. Therefore let's abandon all-caps acronyms in CamelCase, resulting in PciIntxRoutingNotifier, QemuSgList, VfioIntx.

---

This is an attempt to formalize and get agreement on name changes suggested for the vfio-pci driver. VFIO is very prone to these naming problems. I don't expect to do any massive code churn to correct these, but I will update vfio-pci to whatever outcome we decide and at least we'll have a reference rather than per maintainer policy. Thanks,

Alex

 CODING_STYLE |    5 +++++
 1 file changed, 5 insertions(+)
CODING_STYLE +0 -0
index dcbce28..e45ed1a 100644

CODING_STYLE and is therefore likely to be changed. · line 60

Quoted 8 lines
CODING_STYLE +5 -0
@@ -53,6 +53,11 @@ and is therefore likely to be changed.
 When wrapping standard library functions, use the prefix qemu_ to alert
 readers that they are seeing a wrapped version; otherwise avoid this prefix.
 
+When making use of acronyms in CamelCase only capitalize the first character
+of the acronym.  This promotes readability and clearly defines the start of
+each word or acronym.  For example, instead of PCIBAR, use PciBar.  In place
+of QEMUDMAList, use QemuDmaList.
+

I'd prefer not to do this.

Quoted 5 lines

We do both within QEMU and I think that's fine. By choosing one vs. the other we just create a lot of friction because now people have to introduce structures that aren't consistent with the rest of the file.

Either is fine IMHO.

Fair enough, thanks,

Alex

#5 lore raw
In reply to Anthony Liguori
Quoted 43 lines · Anthony Liguori
Quoted 30 lines · Alex Williamson

When creating structure names in CamelCase, it's easy to have back-to-back capitals when using acronyms (ex. PCIINTxRoutingNotifier, QEMUSGList, VFIOINTx). In the worst case these can look like macros, but even adjoining a single, all-caps acronym makes it more difficult to interpret. For example, is PCIIntxRoutingNotifier sufficiently more clear? Mixing case, such as VFIOintx isn't truly CamelCase. Therefore let's abandon all-caps acronyms in CamelCase, resulting in PciIntxRoutingNotifier, QemuSgList, VfioIntx.

---

This is an attempt to formalize and get agreement on name changes suggested for the vfio-pci driver. VFIO is very prone to these naming problems. I don't expect to do any massive code churn to correct these, but I will update vfio-pci to whatever outcome we decide and at least we'll have a reference rather than per maintainer policy. Thanks,

Alex

 CODING_STYLE |    5 +++++
 1 file changed, 5 insertions(+)
CODING_STYLE +0 -0
index dcbce28..e45ed1a 100644

CODING_STYLE and is therefore likely to be changed. · line 60

Quoted 8 lines
CODING_STYLE +5 -0
@@ -53,6 +53,11 @@ and is therefore likely to be changed.
 When wrapping standard library functions, use the prefix qemu_ to alert
 readers that they are seeing a wrapped version; otherwise avoid this prefix.
 
+When making use of acronyms in CamelCase only capitalize the first character
+of the acronym.  This promotes readability and clearly defines the start of
+each word or acronym.  For example, instead of PCIBAR, use PciBar.  In place
+of QEMUDMAList, use QemuDmaList.
+

I'd prefer not to do this.

Quoted 3 lines

We do both within QEMU and I think that's fine. By choosing one vs. the other we just create a lot of friction because now people have to introduce structures that aren't consistent with the rest of the file.

I think PCIBAR and PciBar look equally ugly, so I'd agree.

Quoted 11 lines

Either is fine IMHO.

Regards,

Anthony Liguori

Quoted 3 lines
CODING_STYLE +0 -0
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one