`
qiuqiao2000
  • 浏览: 30739 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

TPTP Code Review规则

阅读更多

 

Rule

规则

AWT

Avoid using java.awt.peer interface directly

不要直接使用java.awt.peer接口

Casting

Avoid returning java.lang.Object,downcast to specific type instead

不要直接返回java.lang.Object,尽量转换成具体的类型

Avoid casting primitive types to lower precision

不要把原始类型转换成更底层的类型

Cloneable

Implement Cloneable when you override clone()

覆盖clone()方法时,最好实现Cloneable接口

Avoid implementing Cloneable without overring clone()

如果没有覆盖clone()方法,就不要实现Cloneable接口

Always invoke super.clone() from a clone()

clone()方法中总是调用super.clone()

Comparison

Avoid using java.lang.Class.getName() to compare classes

不要使用java.lang.Class.getName()来比较类

Always override both java.lang.Object.equals() and java.lang.Object.hashCode()

要覆盖java.lang.Object.equals() java.lang.Object.hashCode()

Always use instanceof in an equals() method implementation

在实现equals()方法时要使用instanceof操作符

Always place constants on the left side of the equals()

要把常量放在equals()方法的左边

Avoid using == and != for java.lang.Object comparisons

不要使用== !=来比较ava.lang.Object

Conditional

Avoid using negation in if else conditions

不要在if…else条件中使用否定判断

Avoid using if/else statements for short conditions

不要对短的条件使用if…else语句

Constructors

Avoid calling an abstract method in a constructor in an abstract class

不要在抽象类的构造函数中调用抽象方法

Avoid calling an overridable method in a constructor

不要在构造函数中调用可覆盖的方法

Declaration

Avoid C-styntax when declaring arrays

在声明数组时不要使用C风格的语法

Avoid using explicit string literals, declare constants instead

不要直接使用明文字符串,把它声明为常量

Avoid using interfaces or abstract classes just to declare common constants

不要仅仅为了声明通用的常量而使用接口或抽象类

Avoid declaring variables of basic and array types in the same statement

不要在同一个语句中声明基本类型变量和数组变量

Avoid declaring multiple variables in a single statement

不要在一个语句中声明多个变量

Exceptions

Avoid catching a checked exception that is not thrown within the try{} block

不要捕获try{}语句块中没有抛出的Exception

Avoid using instanceof operator to check the type of exception in the catch clause

不要在cathch语句中使用instanceof操作符来判断Exception的类型

Always list specific checked exceptions in the throws clause

throws语句中列举出所有确定的Exception

Initialization

Avoid changing the value of a method parameter

不要改变方法的参数

Avoid chaining assignment operators

不要进行连锁赋值操作

Always initialize static fields

要初始化静态域

Loop

Avoid assigning loop control variables in the body of for loops

不要在循环体中给控制循环的变量赋值

Avoid using continue statements

尽量不要使用continue语句

Avoid a for loop without a condition

不要使用没有条件控制的for循环

Avoid a for loop without an initializer and an incrementor

不要使用没有初始状态和增加器for循环

Null

Avoid returning null instead of empty array

不要用null代替空数组返回

Avoid returning null instead of Enumeration

不要用null代替枚举类型返回

Avoid returning null instead of Iterator

不要用null代替迭代返回

Portability

Avoid hard coding file separators when creating a java.io.File

在创建java.io.File时,不要硬编码文件分隔符

Avoid hard coding \\n and \\r as line separators

不要使用硬编码\\n \\r作为换行符

Avoid calling java.lang.System.getenv()

不要调用java.lang.System.getenv()

Reflection

Avoid calling java.lang.Class.getDeclaredField()

不要调用java.lang.Class.getDeclaredField()

Avoid calling java.lang.Class.getDeclaredMethod()

不要调用java.lang.Class.getDeclaredMethod()

Avoid calling java.lang.Class.getField()

不要调用java.lang.Class.getField()

Avoid calling java.lang.Class.getMethod()

不要调用java.lang.Class.getMethod()

Serialization

Always declare readObject() and writeObject() as private in externalizable or serializable classes

ExternalizableSerializable接口的实现类中,要把readObject() writeObject()方法声明为私有的

Always declare readResolve() and writeReplace() as protected in externalizable or serializable classes

ExternalizableSerializable接口的实现类中,要把readResolve () writeReplace ()方法声明为保护的

Avoid declaring non-transient fields of non-serializable type inside of a serializable class

不要在Serializable接口的实现类中声明非Serializable类型的非transient

Always create a static final serialVersionUID field in serializable classes

Serializable接口的实现类中创建一个static finalVersionUID

Avoid declaring transient fields in non-serializable classes

不要在非Serializable接口的实现类中声明transient

Statement

Avoid empty if statements and empty loops

避免空的if语句和空循环

Always surround if and loop statements with curly braces

if和循环语句放在括号中

Switch

Avoid switch statements with few branches, use if else instead

if...else语句替换分支很少的switch语句

Always provide break at the end of every case statement

在每个case语句后面加上break语句

Always provide the default label in switch statements

switch语句提供defaul标签

Threads

Avoid extending java.lang.Thread

不要扩展Thread

Avoid using java.lang.Object.notify(), use java.lang.Object.notifyAll() instead

java.lang.Object.notifyAll()代替java.lang.Object.notify()

Avoid overriding a synchronized method with a non-synchronized one

不要用synchronized方法覆盖非synchronized方法

Avoid using synchronized modifier in method declaration

不要在方法的声明中添加synchronized修饰符

Avoid using "this" as a lock in synchronized statements

Avoid using "this" as a lock in synchronized statements

不要在synchronized语句使用this

Avoid using java.lang.Object.wait() outside of a while loop

不要在while循环之外使用java.lang.Object.wait()

Avoid using while sleep, use wait notify instead

wait notify替代while sleep

分享到:
评论

相关推荐

    Eclipse TPTP

    ### Eclipse TPTP:利用TPTP进行性能监视详解 #### 标题解析与扩展: **Eclipse TPTP**,即Eclipse Performance Test and Tuning Platform(性能测试与调优平台),是Eclipse下的一个插件,专门用于对应用程序进行...

    TPTP详细教程

    **TPTP(Test and Performance Tools Platform)**是Eclipse基金会的一个开源项目,专注于软件测试和性能分析。这个工具平台为开发人员、测试人员以及性能工程师提供了集成化的环境,以进行自动化测试和性能评估。本...

    使用Websphere的TPTP工具进行性能分析和监控

    TPTP工具可以通过IBM提供的官方网站下载,推荐下载TPTP-all-in-one package,这是一个包含TPTP插件的Eclipse集成开发环境。下载并解压后,便可以直接运行eclipse.exe启动Eclipse,并安装TPTP插件。此外,通过网站...

    Eclipse TPTP平台配置详细步骤Ver1.0

    ### Eclipse TPTP 平台配置详细步骤 #### 一、运行环境说明 为了确保Eclipse TPTP平台能够正常运行,需要满足以下系统环境需求: - **JDK版本**:1.5及以上版本。 - **操作系统**:Windows XP。 - **应用服务器**...

    eclipse TPTP 资源 包

    eclipse tptp THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE ...

    Eclipse TPTP平台配置详细步骤Ver1.0(永久空间).doc

    Eclipse TPTP (Test and Performance Tools Platform) 是一个开源项目,主要目的是提供一套集成的开发和测试工具,用于性能测试和性能分析。本指南将详细介绍如何配置Eclipse TPTP平台,以便对Tomcat服务器进行远程...

    TPTP详细教程,中文版

    - **TPTP Platform**:这是基础平台,为用户界面开发、数据收集、基于规则的数据查询和应用程序控制提供基础服务。它包含了编程接口、可重用向导以及后台数据采集功能,支持本地和远程程序。 - **TPTP Testing ...

    TPTP Web TEST-开源

    在TPTP Web TEST中,用户可以创建四种类型的断言: 1. **文本断言**:检查页面上是否存在特定的文本字符串。这适用于简单的文本匹配场景,例如确认按钮上的文字或页面标题。 2. **正则表达式断言**:允许更复杂的...

    性能测试工具tptp使用

    火龙果软件工程技术中心 程序...环境本次用的tptp版本是4.4.0.2是当时比较稳定的版本,再多说一句,本想下载tptp的4.4.1但是下载所有eclipse官方所有依赖的插件运行后一直都启动不了agentcontroller(tptp依赖的一个非常

    Static code analysis

    - 列出符合特定规则的代码行,按规则或按包/类组织,帮助代码审查和去除不良编码实践。 - 识别需要重构的重复代码。 #### 期望的成果 - **静态分析的特点**:仅基于类型信息等静态信息进行分析,无法考虑运行时...

    Eclipse Test and Performance Tools Platform 简介

    ### Eclipse Test and Performance Tools Platform (TPTP) 知识点详述 #### 一、TPTP概览 **Eclipse Test and Performance Tools Platform**(简称TPTP)是Eclipse基金会旗下的顶级项目之一,它提供了一套全面且可...

    tftp安装包

    tftp安装包,下载了即可安装!!!!!!!!!!!!!!!!!!!!!!!!!!

    Theory-Prover:一阶逻辑定理的证明,其中没有符号的解释是有序解析的,基于自动推理过程中给定子句àla Otter和àla E的循环。 接受TPTP库中的入站文件

    理论验证 ======================================== Java的一阶定理证明者在Java中的实现,而没有符号通过给定子句la Otter和àla E的基于循环的有序解析来解释。 用户可以选择几种类型的排序和分辨率。...

    Profiling and Testing with Test and Performance Tools Platform.pdf

    ### TPTP平台概述 《Profiling and Testing with Test and Performance Tools Platform》是一份由IBM Canada的Eugene Chan和Jonathan West共同撰写的文档,主要介绍了TPTP(Test and Performance Tools Platform)...

    十六进制转化

    4. **ASCII编码**:提到`ascii.exe`,这可能涉及到ASCII(American Standard Code for Information Interchange,美国信息交换标准代码)编码。ASCII是一种字符编码标准,使用7位二进制数来表示128种不同的字符,...

    eclipse插件大全

    在提供的压缩包文件名称“eclipse-code-formatter.xml”中,我们可以推断出这是Eclipse的一种配置文件,用于定义代码格式化规则。Eclipse Code Formatter是Eclipse内置的一个功能,它允许开发者定制代码的缩进、空格...

    emf-sdo-xsd-SDK-2.3.2.zip

    它是XML文档验证的重要工具,确保XML文档遵循预定义的规则。 5. **emf-sdo-xsd-SDK-2.3.2**: 这个插件集成了EMF对SDO的支持,并提供了XSD的处理能力。它使得开发者可以利用EMF的模型驱动开发能力,处理基于SDO的...

    Eclipsecon08-Profiling.ppt

    【Eclipse TPTP项目概览】 Eclipse TPTP(Test and Performance Tools Platform)是IBM和Intel等公司合作开发的一个开源项目,旨在为Java应用程序提供测试和性能优化的工具平台。自2002年作为Eclipse Tools Project...

Global site tag (gtag.js) - Google Analytics