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

Encourage alignment of statements #8

Open
mkristien opened this issue Oct 26, 2019 · 7 comments
Open

Encourage alignment of statements #8

mkristien opened this issue Oct 26, 2019 · 7 comments
Labels
accepted Change accepted

Comments

@mkristien
Copy link
Contributor

mkristien commented Oct 26, 2019

This can be in variable declarations or statements:

constexpr uint16_t kIdBase      = 300;
constexpr int      kIdIncrement = 10;
constexpr double   kIdSize      = 5;

vs

constexpr uint16_t kIdBase = 300;
constexpr int kIdIncrement = 10;
constexpr double kIdSize = 5;
@georgeka98
Copy link

First one looks cleaner and easier to read. I vote for first style.

@brano2
Copy link
Member

brano2 commented Oct 27, 2019

It is harder to maintain but that is usually outweighed by the better readability so 👍

@neilweidinger
Copy link
Member

I think maybe if one needs to define more than five or so variables at once then yes, this style would make sense, but for simple one liners this would just be unnecessary. Also looks very old school imo.

@brano2
Copy link
Member

brano2 commented Oct 27, 2019

It makes no difference for one liners. I'd definitely make it a recommendation rather than a strict rule. If you only have 2-3 variables that are completely unrelated, it probably doesn't make sense. But for the cases like above (which are fairly common), it improves readability quite a bit.

@brano2
Copy link
Member

brano2 commented Oct 27, 2019

Also looks very old school imo.

Says someone who uses vim as their primary text editor.

@neilweidinger
Copy link
Member

Says someone who uses vim as their primary text editor.

Vim is timeless 😛

@brano2
Copy link
Member

brano2 commented Oct 30, 2019

@mkristien can you get your vote in as well so it's clear we have a difference of +3? Then someone create a PR.

@brano2 brano2 added the accepted Change accepted label Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Change accepted
Projects
None yet
Development

No branches or pull requests

4 participants