-
Notifications
You must be signed in to change notification settings - Fork 23
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
Naming and Layout/Style Proposal #15
Comments
From @Jamiras on April 7, 2018 3:0 I was disappointed by the fact that I agree with most of your suggestions, including all of the editor settings (which I believe are the default) and macro usages. I prefer I don't really have a preference on whether or not class fields should be prefixed (i.e. The Hungarian variable names and much of the current formatting style are from before my time. If we wanted to change things to enforce a standardized style across the codebase, I don't think there would be much push back. The codebase has been fairly stable for the last month or so, it seems like it would be a good time to attempt something like this. I'd recommend limiting the first pass to whitespace, and tackling names later. |
From @SyrianBallaS on April 9, 2018 19:4 I'm honestly fine with anything as long as everyone's on the same page. Was just giving some insight based on my experience. |
I've been looking at the code, and have the following proposal:
not
not:
not
Once a proposal is agreed upon, we can define VS settings to enforce most of the proposal and autoformat the codebase, then use this ticket to commit the whitespace changes. Non-whitespace changes (like updating variable names) should not be made as part of this ticket. New code should follow any accepted styles, but existing code will be grandfathered in. |
Just a quick question about the namespaces. Did you want the sub-namespaces to hide implementation or expose it? If it's the later they should be Everything else seems acceptable. Though I personally disagree with some of it, but it's OK. Edit: @Jamiras I'm gonna hold off on doing anything on that #23 PR until I have a better understanding on unicode conversions. |
From what I understand, inline namespaces are meant for versioning. If you put something in a namespace for any other reason, it shouldn't be inline. Namespaces should be used to group similar classes and keep them out of the current scope unless explicitly required. With proper segregation, it' takes more effort to create inter dependencies. Classes in |
Majority of these are in line with standard coding conventions. Don't have an issue with that for the most part. I do have comments on 6, 7, 11, and 14. For 6 and 7, I personally prefer Hungarian notation. Just helps me to identify things faster and more concisely. As for 10 and 11, I agree completely with braces on separate lines, but I'm not too onboard with removing braces only if no branches require them. I would prefer to put braces where they are needed and exclude them when they aren't.
14 is a big issue for me. Single-line ifs are something I use a lot depending on the length of the statement. |
Since most of the code already uses Hungarian notation, I'm fine changing 6 and 7 to support that. I'm strongly against 14. Putting the Regarding 11: Symmetry improves readability, but I'm flexible. I've drafted an updated proposal here: https://github.com/Jamiras/RASuite/blob/master/CONTRIBUTING.md Are there any other changes or additions that are desired? I'll look at creating a VS settings file and create a PR to globally reformat the code (whitespace only) next weekend. |
14: From my pov, it increases readability, as it generally makes blocks smaller and requires less scrolling. 11: Flexible on this one as well, was just speaking what I typically do. My argument is mostly the same as my above statement. I just like smaller blocks. |
I'm fine with most of the proposal but I think the braces on control flow I'll try to tweak my prs to conform to this standard when I can. Edit: Not a big deal now, but I think if we absolutely must use pointers (from what I could tell it can be easily avoided, directly at least, Window Handles would need custom deleters because handles don't have destructors) then we need to use ownership semantics via if you are worried about size, the size of the Also I noticed the .editorconfig isn't added as a solution/project file, that'll handle the indent spacing, adding the last new line (GitHub complains about that) automatically. That's something to consider when you autoformat. |
Not sure if it's common knowledge, but I think you should state that this repository should be a remote when forking when new stuff is added here so the forked repo can pull in the new changes. |
@Jamiras I think you should mention in the CONTRIBUTING file that people should back up their Visual Studio settings and import the provided Visual Studio settings in the repository if they want an eaiser time using the formatting conventions.. |
From @SyrianBallaS on April 3, 2018 19:25
Preface
OK, so I noticed the .editorconfig file got accepted. That will definitely help a little bit, but ultimately not solve the root issue of inconsistent style. It is understandable that inconsistencies are undesirable and wish to propose a solution. Some of these come from the reviews in pull request #49, others from myself, and, isocpp. For some insight, I professionaly program in ASP.NET Core so some stylings may differ from isocpp.
On another note (somewhat related), I propose using a package.config/project.json file for binaries to prevent changes to library files (plus it will save space in the repo). Had one a long time ago but deleted the repo that was in it because it was too far gone (incorrect).
The lead engineer (I'm assuming @ScottFromDerby) will have the final say.
This is just a proposal, what's actually going to be used should be formalized in the wiki or a CONTRIBUTING file. This is just to give some ideas.
Naming
For a lot of these, you can easily change them using
ctrl+alt+f
.Data Members
I would prefer data members be in snake-case with a leading underscore (i.e.,
some_var_
) as encoding type information is redundant. However, if the majority strongly desire Hungarian Notation that's fine too.Methods
Event Handlers
Other Member functions, internal functions(helpers), and global functions
Classes/Structs
_RA
to make it more consistent. It's defined like this:#define _RA ::ra::
Enums
is_equality_comparable
andis_lessthan_comparable
to validate something is comparable it looks for the equality and lessthan operator. It will be important for some enums. If those validations pass instatic_assert
you can useusing namespace std::rel_ops
(suggest at function scope) to have the rest of the operators done for us. Some other operator overloads might be necessary as well but it's trivial.Layout
More Formatting (not covered by .editorconfig)
To check/uncheck, go to Tools->Options->Text Editor->C/C++->Formatting->(*something). *something will depend on what we're trying to do. Some of these might be checked/unchecked already.
To save time I'll just put a screen shot
I'd suggest for everything besides multiline functions and long loops (the initialization part) put a brace on the same line with one space before it.
Limit Macros
Unacceptable Uses
constexpr
(wasn't fully implemented (still isn't, noconstexpr if
) by Microsoft until C++17 but did exist in C++14).#define SOME_STRING "a string"
, considerinline constexpr const char* some_string{"a string"}
constexpr if
`is short for "constant expression" and can only be used on types that can be resolved at compile time.zcstring
which is a wrapper forconst char*
which is bounded.std::function
withstd::bind
. (creates a function object instead of a pointer, which automatically deallocates).int some_fn(char c, std::string str);
using some_fn_t = decltype(&some_fn);
const auto& another_fn{static_cast(some_fn_t)(some_fn)};
It didn't like the angle brackets.
another_fn
is an alias tosome_fn
; Did some extra steps because that's for overloads. Overloaded template functions needs parameter forwarding but we'll worry about that later.using
. Instead oftypedef int some_type ;
considerusing some_type = int;
.Acceptable uses
HANDLE_MSG
.Copied from original issue: RetroAchievements/RASuite#73
The text was updated successfully, but these errors were encountered: