Where can I find the OFFICIAL Java Coding/Style Standards? [closed]

三世轮回 提交于 2019-11-30 23:09:08

问题


I use CheckStyle plugin for Eclipse and it does a wonderful job. I would like to know if there an official Code/Style standard (and there should be!) out there by Sun/Oracle... The ones I am finding are so out-dated, they don't even include any Java 1.6 specific syntax, etc...

Here is what I found so far:

http://developers.sun.com/sunstudio/products/archive/whitepapers/java-style.pdf (last modified 2000)

http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html (last modified 1999 - CheckStyle website references this)

I understand that to a degree most of the Java syntax has not changed much but you'd think it wouldn't be over 10 years old!!! Any ideas where to find an updated version or if there is any that I am just not finding?

Thanks


回答1:


Try looking at the -Xlint compiler flag for javac for a programmatic check (if that's your question). It checks most things for you.

Also, what's wrong with having a code style document that's > 10 years old? That means the language is fairly stable and older code looks much like newer code, making maintenance easier. The library may have expanded but much of the syntax is identical. Your second link is what my searches returned and seems very comprehensive.

EDIT: If you want the nitty gritty details on the new Java syntax, check out the Java Specifications.




回答2:


To the best of my knowledge the internal Sun coding stds document was never officially updated to include conventions to encompass language changes such as Generics, Annotations, or now (in JDK 8) Lambdas etc.

I personally have always used the empirical style derived from the JDK itself, i.e if my code doesn't look like JDK code, then I am not following the coding practice.




回答3:


The links above are broken now since Oracle reorganized their web site.

http://web.archive.org/web/20090911103851/http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html



来源:https://stackoverflow.com/questions/10093596/where-can-i-find-the-official-java-coding-style-standards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!