-
Notifications
You must be signed in to change notification settings - Fork 11
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
STYLE: Distinguish ivars from local vars #8
Conversation
@fbbdev Fabio, I think this project has great potential. I am making recommendations early in the project regarding some style and conventions that will have long term benefits of cultivating a vibrant user and developer base. Please consider this recommendation. If you are satisfied with these changes, I can work to implement them over the next few days. Regards, |
Hans, I'm fine with these changes as long as struct members and public class members retain normal names (as recommended by the Google Style Guide). So in structs (like If you're fine with the above requirement, go ahead with the implementation; I will avoid changing class members until I get your pull request, in order to minimize conflicts. Thank you for your interest in this project :) |
@fbbdev Fabulous. I think your proposal is perfectly balanced between pragmatic and conformant. |
@fbbdev This is a fairly common approach to managing structs and classes. I would recommend converting the "Color" struct to a class. Do you have a counter argument for your distinction between classes and structs? Hans |
0de9c56
to
2b76e09
Compare
This now has private class ivars with suffix of "_". |
A common method for improving code readability is to conform to a standard naming convention for class & struct ivars. The two most prevalent mechanisms for accomplishing this are: 1) ITK/VTK and many other projects ivars beging with "m_" for object ivars, and "s_" for static class ivars. 2) Google Style ivars are suffixed with "_" This practice reduces burden of maintenance for community developed software by inherently providing contextual and intent information directly in the variable name. Using suffixed ivars for indicating private class members is adopted. struct members and public class members retain normal names (i.e. not suffixed) (as recommended by the Google Style Guide). So in structs (like Point, Rect and others) we should still change method argument names in order to avoid shadowing.
2b76e09
to
8c4b0c7
Compare
@hjmjohnson I definitely agree with google's distinction. Yet I interpret it more liberally:
A similar case is On the other hand I understand the phrase 'provide behavior' as if meaning 'have side effects' or 'implement control logic'. |
Fixed classes: - margin_line - frame_line - vbox_line - hbox_line
A common method for improving code readability
is to conform to a standard naming convention
for class & struct ivars. The two most prevalent
mechanisms for accomplishing this are:
ITK/VTK and many other projects
ivars beging with "m_" for object ivars, and "s_"
for static class ivars.
Google Style
ivars are suffixed with "_"
This practice reduces burden of maintenance for
community developed software by inherently providing
contextual and intent information directly in the
variable name.