-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add initial Jackson Coding Style guide #201
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
Conversation
I code mainly in Scala and that language has tools to validate and even reformat code based on agreed styles. If you can't automate it, I would suggest it is more time consuming than it's worth to argue about indents in PRs. Java community might have tools but may not. |
https://code.revelc.net/formatter-maven-plugin/ is an example of a tool that could be looked at. |
I concur. The intention was that this new "Jackson Coding Style Guide" will serve both as a guideline, but also as specification for such automated formatter There is also https://github.com/google/google-java-format |
Quick note: I have not have good experience with auto-formatters so I am generally -1 for using them in fully automated mode. Some aspects could be useful (automatic trimming of trailing spaces, tabs to spaces), but almost universally there are stylistic exceptions that cannot be automated. So I don't have much expectation that formatters would be valuable addition. But I do think documenting style itself, important parts, is a good thing: most contributors follow existing style anyway, but spelling out intent -- and especially CURRENT thinking (some code may follow older style; style evolves along with code). But I also agree that what we do not want to do is to spend lots of (or, any... ) additional time worrying about style-compliancy. Use of auto-formatters is definitely one way to do that; the other is to do things in eventually consistent way. |
Looks good so far! One other thing we could mention is the use of
Yet another is maximum line length. This is tricky, because strict adherence can lead to really awkward lines, coupled with indentation. So I think we should probably just suggest lines not to exceed... I don't know. Looks like 90 characters is width of lines I see (80 or 76 is traditionally recommended for all TTYs). For Javadocs we could/should recommend strict adherence. Maybe starting with max 100 characters. Which leads to question of what to mandate about Javadocs more generally. |
Looks good @JooHyukKim. Aside from question of "static import" ordering, one other existing rule I realized related to test class naming:
It is worth noting that one of above is (was?) actually required by JUnit (wrt Maven pom settings) to include test classes: classes that don't start or end with Similarly there is specifically named |
Added |
After the |
Yes, I think getting a simple agreed-upon structure makes sense; easy to add/modify as necessary. Will read through once more now. |
Initiates a long journey of ... FasterXML/jackson-databind#4156
If we start this, everyone's advised to link any discussions regarding coding-style, or conventiuon back to this style-guide