orc icon indicating copy to clipboard operation
orc copied to clipboard

[C++] uniform identifiers naming style.

Open ffacs opened this issue 1 year ago • 7 comments

          Unrelated to this PR: we have many weird `_xxx` variable names appearing in the function signature. I'm thinking to do something like apache/arrow, which only use `xxx_` as the name of private class member variables. In this way, we can get rid of the weird case like this.

Originally posted by @wgtmac in https://github.com/apache/orc/pull/1761#discussion_r1468513025

ffacs avatar Mar 14 '24 09:03 ffacs

The following .clang-tidy file can help us to check naming styles mismatch. And we can use clang-tidy to fix them.

Checks: "-*,
        readability-identifier-naming,
"

CheckOptions:
  [
      { key: readability-identifier-naming.PrivateMemberSuffix,   value: "_"  },
  ]

WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle:     none

But there is a problem that some protected/public variables need to be initialized on construction, what should the naming of corresponding parameter should be? What do you think? @wgtmac @dongjoon-hyun

ffacs avatar Mar 14 '24 09:03 ffacs

Could we add NOLINT to those public/protected variables?

wgtmac avatar Mar 14 '24 09:03 wgtmac

Could we add NOLINT to those public/protected variables?

Sorry for my confusing expression. What I mean just like below https://github.com/apache/orc/blob/e1f185eedd7dc0d9d60339117c9299f5b26ddeaf/c%2B%2B/src/ConvertColumnReader.cc#L26-L33

The readType is a protected member of ConvertColumnReader. if we still use readType as the name, we can`t uniform the naming of constructor parameter.

ffacs avatar Mar 14 '24 10:03 ffacs

What about this?

  • Use _ suffix for private member variable.
  • Do not use _ suffix for protected and public member variable.
  • Avoid any _ prefix and suffix in any function parameter.

wgtmac avatar Mar 14 '24 14:03 wgtmac

Can we borrow some existing styles from other open source projects? IIRC, initially, @wgtmac mentioned Arrow community. Are the above rules came from Arrow community?

dongjoon-hyun avatar Mar 14 '24 21:03 dongjoon-hyun

For the record, I welcome any linter-based rules. Thank you for making this efforts, @ffacs and @wgtmac .

dongjoon-hyun avatar Mar 14 '24 21:03 dongjoon-hyun

We could leverage https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html for variable naming. Apache Arrow used cpplint approach which we cannot borrow: https://github.com/apache/arrow/blob/main/cpp/build-support/cpplint.py

wgtmac avatar Mar 15 '24 01:03 wgtmac