-
-
Notifications
You must be signed in to change notification settings - Fork 336
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
Decide on Allman vs K&R brace position and stay consistent #375
Comments
Yes, braces at end of line is fine by me. We should maybe do a once over for code style before release, there's lots of |
A convention was snake case for local variables :-) It is NOT very common in Java, but fwiw, I grew to like it and still do it out of habit until I stop myself! |
Heh. We always did Ning style in JDBI, why change now? It is "allman" style for classes and methods and K&R for control statements on the account that each is better readable in their respective situations. Also, it is if (...) {
...
}
else {
...
} and not if (...) {
...
} else {
...
} on the account that the former allows you to select the full else block without cursor-left and right movement and the latter does not (hello, peeps stuck on vi :-) ) . |
Whatever we do, I feel like it's time to have the checkstyle plugin start validating formatting during builds. |
Ah of course, the bikeshed issue attracts the most commentry ;) I also do not care, sticking with the existing style is fine, but I agree we should enforce it one way or the other. |
I propose to switch to the K&R style which is rather simple to enforce with checkstyle and usually is set as the default for the majority of Java IDEs. |
I personally like the look of Allman brace style. However I would argue that we should switch to K&R because it's what the vast majority of Java devs use. Allman braces just add work to PRs. e.g. #474 (comment) In fact I wouldn't mind going a step further, and just adopting Google's Java Style Guide:
|
I generally am OK with Google's style guide. However, some things are surprising (seems like they like 2 space indents? 4 seems very standard for Java) and I worry it's over-specified for what we care about. I can see us spending a fair amount of time messing around with Checkstyle and getting frustrated over anal interior spacing rules 😒 I will second that #474 showed Allman style to be very verbose in some cases. It really annoyed me on that PR in particular. Do we have any data to back up the assertion of "Java programmers like K&R"? I found this: http://sideeffect.kr/popularconvention/#java This will also cause merge pain from master to jdbi3 as we try to port features over. |
I'll also go on the record as not really caring too much about this either way. I like readable code over debating about style rules :) |
How about we table this for now. When we're ready to come back to this (toward the end of the release), I'll do a spike on switching to Google style, and then we can debate based on the observed impact. |
We use a derivative of the Ning style (I'm guessing that's @martint style) in Airlift and Presto and is quite close to what Jdbi uses now. Our Checkstyle rules are good enough now that formatting nits are relatively rare in code review. Having the checker run in Travis means that people see it and fix it before review. I think that, psychologically, people are much more accepting when this is automatic as part of the build. No one argues about style rules, they just notice the build failed and fix it. Highly recommended, no matter what style you choose. IntelliJ: https://github.com/airlift/codestyle |
Having looked into the google code formatter and the google code style preset in checkstyle--this is probably more trouble than it's worth. @jdbi/contributors I'm good to close this if the rest of the team is in agreement. |
All bikeshed colors matter :P |
Allman:
Kernighan & Ritchie:
The code seems to use lots of both styles, to the point that I'm not sure which one we're going for.
My vote would be K&R style braces (end of line) since the Java ecosystem at large seems to follow it.
The text was updated successfully, but these errors were encountered: