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

Consider reordering members so private fields are at the top #57

Open
tannergooding opened this issue Oct 1, 2019 · 1 comment

Comments

@tannergooding
Copy link
Contributor

commented Oct 1, 2019

Currently, the header files are declaring fields at the bottom of the class (which I believe is "standard" C++ practice).

This frequently leads to code like:

class MyClass {
public:
    inline int getValue() const;

private:
    int _value;
};

inline int MyClass::getValue() const {
    return _value;
}

Reordering these such that fields are at the top could simplify this greatly:

class MyClass {
private:
    int _value;
public:
    inline int getValue() const {
        return _value;
    }
};
@tannergooding

This comment has been minimized.

Copy link
Contributor Author

commented Oct 1, 2019

One example is in GeoVector, where almost half the lines are redeclaring the template and method signature: https://github.com/novelrt/NovelRT/blob/master/src/GeoVector.h#L62

The ordering also makes it easier to see the state/layout of a given type; without first needing to find the end of the class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.