Jtest logo




Contents  Previous  Next  Index

MISC.ASFI


A class with only "abstract" methods and "static", "final" fields should be declared as an "interface"

Description

This rule flags classes that should be declared as "interface"s.

"abstract" classes that only contain method signatures and "static", "final" fields should be declared as "interface" because they are effectively the same. A "class" can extend only one "class" but it can implement multiple interfaces.

Example

 package MISC;
 
 abstract class ASFI {
     abstract void method();
     final static String ID = "MISC_ASFI";
 }

Repair

Replace "abstract" class to an "interface".

 package MISC;
 
 interface ASFI {
     void method();
     String ID = "MISC_ASFI";
 }

Reference

Warren, Nigel, and Bishop, Philip. Java in Practice. Addison-Wesley, 1999, pp.22-23.


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft