#534 Black List for Interface method definition

open
nobody
Check (274)
5
2012-10-10
2010-02-18
Gene Wu
No

Certain java interfaces need to be restrict not to use a set of Java classes. For example, the Vector and ArrayList, in this case, Collection and List.

It could be used to prevent API interface from using incorrect classes, for example, web services.

Also, we could apply it to any project to loose couple the implementation from interface definition.

Discussion

  • Gene Wu
    Gene Wu
    2010-02-18

    I had a check wrote by myself. Maybe I can contribute to the repository.

     
  • Oliver Burn
    Oliver Burn
    2010-02-22

    Could you please give a detailed example of what the check should detect. I do not understand at the moment. Thanks.

     
  • Gene Wu
    Gene Wu
    2010-02-23

    Sorry for my bad English.

    For example:

    public interface OracleTestDAO
    {

    void testVector(Vector vector);
    Vector testVector();
    
    void testArrayList(ArrayList arrayList);
    ArrayList testArrayList();
    

    }

    From best practice's perspective, it's not very good to export ArrayList and Vector as parameter or return type of interface method.

    Some ancient code may have this issue, better to identify them and fix them step by step. Also, we can use it to restrict interface design.