Java编码风格 [英] Java coding style

查看:95
本文介绍了Java编码风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何保持标准的编码?有 stylecop resharper for C#。有没有任何工具/ eclipse插件的代码分析在Java? .sourceforge.net /rel =nofollow noreferrer> http://checkstyle.sourceforge.net/ 。


< >

Checkstyle是一个开发工具,帮助程序员编写符合编码标准的Java代码。它自动化检查Java代码的过程,以免人类无聊(但重要)的任务。这使它非常适合那些想要实施编码标准的项目。
Checkstyle是高度可配置的,可以支持几乎任何编码标准。提供了一个支持Sun代码约定的配置文件示例。







PMD与JDeveloper,Eclipse,JEdit,JBuilder,BlueJ,CodeGuide,NetBeans / Sun Java Studio Enterprise / Creator,IntelliJ IDEA,TextPad,Maven,Ant,Gel,JCreator ,and Emacs。







FindBugs使用静态分析来检查Java字节码对错误模式的发生。静态分析意味着FindBugs可以通过简单地检查程序的代码找到错误:执行程序不是必需的。这使得FindBugs非常容易使用:一般来说,你应该能够使用它在下载它的几分钟内在代码中查找错误。 FindBugs通过分析Java字节码(编译的类文件)来工作,所以你甚至不需要程序的源代码来使用它。因为它的分析有时不精确,FindBugs可以报告假警告,这是不表示真正错误的警告。在实践中,FindBugs报告的错误警告率小于50%。



How do you keep yourself coding to standards? There is stylecop and resharper for C#. Are there any tools/eclipse plugins for code analisys in Java? Which of them do you use?

解决方案

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard. Checkstyle is highly configurable and can be made to support almost any coding standard. An example configuration file is supplied supporting the Sun Code Conventions. As well, other sample configuration files are supplied for other well known conventions.

PMD is integrated with JDeveloper, Eclipse, JEdit, JBuilder, BlueJ, CodeGuide, NetBeans/Sun Java Studio Enterprise/Creator, IntelliJ IDEA, TextPad, Maven, Ant, Gel, JCreator, and Emacs.

FindBugs uses static analysis to inspect Java bytecode for occurrences of bug patterns. Static analysis means that FindBugs can find bugs by simply inspecting a program's code: executing the program is not necessary. This makes FindBugs very easy to use: in general, you should be able to use it to look for bugs in your code within a few minutes of downloading it. FindBugs works by analyzing Java bytecode (compiled class files), so you don't even need the program's source code to use it. Because its analysis is sometimes imprecise, FindBugs can report false warnings, which are warnings that do not indicate real errors. In practice, the rate of false warnings reported by FindBugs is less than 50%.

这篇关于Java编码风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆