Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++] uniform identifiers naming style. #1845

Closed
ffacs opened this issue Mar 14, 2024 · 7 comments
Closed

[C++] uniform identifiers naming style. #1845

ffacs opened this issue Mar 14, 2024 · 7 comments
Milestone

Comments

@ffacs
Copy link
Contributor

ffacs commented Mar 14, 2024

          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 #1761 (comment)

@ffacs ffacs changed the title 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. [C++] uniform identifiers naming style. Mar 14, 2024
@ffacs
Copy link
Contributor Author

ffacs commented Mar 14, 2024

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

@wgtmac
Copy link
Member

wgtmac commented Mar 14, 2024

Could we add NOLINT to those public/protected variables?

@ffacs
Copy link
Contributor Author

ffacs commented Mar 14, 2024

Could we add NOLINT to those public/protected variables?

Sorry for my confusing expression. What I mean just like below

ConvertColumnReader::ConvertColumnReader(const Type& _readType, const Type& fileType,
StripeStreams& stripe, bool _throwOnOverflow)
: ColumnReader(_readType, stripe), readType(_readType), throwOnOverflow(_throwOnOverflow) {
reader = buildReader(fileType, stripe, /*useTightNumericVector=*/true,
/*throwOnOverflow=*/false, /*convertToReadType*/ false);
data =
fileType.createRowBatch(0, memoryPool, /*encoded=*/false, /*useTightNumericVector=*/true);
}

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.

@wgtmac
Copy link
Member

wgtmac commented Mar 14, 2024

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.

@dongjoon-hyun
Copy link
Member

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 dongjoon-hyun added this to the 2.1.0 milestone Mar 14, 2024
@dongjoon-hyun
Copy link
Member

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

@wgtmac
Copy link
Member

wgtmac commented Mar 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants