Skip to content

Develop and enforce a consistent naming style #135

Open
@grunt-lucas

Description

@grunt-lucas

Porytiles code uses somewhat inconsistent style conventions. Pick a convention and refactor the code to use it, and stick to it. Document the style in a STYLE.md file. The legacy code currently follows a Java-like style (with some Google mixed in). The C++ Core Guidelines recommend picking a style and then sticking to it.

Style side-by-side comparison can be found here:
https://github.com/motine/cppstylelineup

Missing from this repo is the C++ stdlib style, which basically uses snake_case for everything.

What I've Tried

So far, I have tried Google style: https://google.github.io/styleguide/cppguide.html#Naming
A few things I don't love about Google Style:

  1. snake_case for variables (and optionally for getters/setters), PascalCase for classes/functions is honestly a bit confusing and hard to remember. I find myself absentmindedly using camelCase or PascalCase for variables if I have just finished typing a function/class definition.
  2. While I don't like SHOUT_CASE for constants (macro leakage), I also don't think kGoogleCase is that great. I don't love the little leakage of Hungarian notation into constants when it's not used anywhere else. Advanced IDEs like CLion and VSCode can easily distinguish constants from other variables. They should probably just be named like any other variable. That being said, I do see the argument that it makes them very easily visually identifiable.
  3. Calling methods on objects looks weird, e.g. my_foo_obj.SomeCoolMethod(). You end up with an ugly mix of snake case and Pascal case in the same statement.

Metadata

Metadata

Assignees

Labels

porytiles2Work related to the Porytiles 2 effortrefactoringCode cleanup that doesn't significantly alter functionalityrepo-housekeepingRepository housekeeping

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions