
1 noreplay 2020 年 5 月 6 日 via Android 给热心的楼主大佬点赞 |
2 legiorange 2020 年 5 月 6 日 感谢!一直以来没有人去做这件事情。 |
3 chanchan 2020 年 5 月 6 日 via Android 我怎么记得有人翻译过了呢 |
4 fantastM OP @chanchan #3 是有的,不过这个文档偶尔会更新一下 https://github.com/google/styleguide/commits/gh-pages/javaguide.html,网上搜到的一些译文和原文已经有些偏差......我想着把翻译项目放在单独放在一个 GitHub 仓库上,也是为了后续方便一直维护 |
5 hantsy 2020 年 5 月 6 日 Sun 以前的规范在命名方面规定更细一些。 Google Java Style Guide 最重要是提供了 Eclipse 和 IDEA 配置文件。 个人我还是喜欢 4 空格缩进。 Spring 有专门的项目,来提供统一的 IDEA 配置来规范文件格式。 |
6 aaronysj 2020 年 5 月 6 日 点赞 |
8 fantastM OP @hantsy #5 我倒是知道谷歌还有个类似于 Golang 中 go fmt 命令的项目 https://github.com/google/google-java-format |
9 hantsy 2020 年 5 月 6 日 |
10 hantsy 2020 年 5 月 6 日 参照 readme, https://github.com/spring-io/spring-javaformat/tree/master/.eclipse 下的 Eclipse 配置可以导入 IDEA,Eclipse 。 |
11 hantsy 2020 年 5 月 6 日 Spring Code Style 参照了 Google 版本修改的,https://github.com/spring-projects/spring-framework/wiki/Code-Style 其中就去掉了 2 spaces Indent 。 |
12 yjxjn 2020 年 5 月 6 日 一直在用阿里巴巴的 codestyle,还有插件,也挺好的。 |
13 astkaasa 2020 年 5 月 6 日 via iPhone spring 的都是 tab 缩进 |
15 fantastM OP @hantsy #11 谷歌的风格对代码块要求是缩进 2 个空格 https://google.github.io/styleguide/javaguide.html#s4.2-block-indentation,但是对连续的换行(例如 Stream 的链式调用)要求是缩进 4 个空格 https://google.github.io/styleguide/javaguide.html#s4.5.2-line-wrapping-indent 。 其实我自己也是主张 4 个空格的... |