[concurrency-interest] Navigable{Map, Set} must not inherit fromSorted{Map, Set}

Remi Forax forax at univ-mlv.fr
Mon Sep 5 05:32:03 EDT 2005


David Holmes wrote:

>>Rémi Forax wrote:
>>    
>>
>>>   void doSomething(Set<String> set) {
>>>     if (set instanceof SortedSet)
>>>       // before retrofitting:
>>>       //   it's a tree set, or a wrapper on a tree set
>>>       //   like unmodifiableSet(...)
>>>       // after retrofitting:
>>>       //   oups FastTraversalSet match
>>>     else
>>>       // it's my implementation
>>>   }
>>>      
>>>
>
>Is there some reason you can't invert the test and check for your
>implementation first? That way you don't care what interfaces it implements.
>
>David Holmes
>  
>
I can invert the test but this code was written two years ago and not by me.
It works so i prefer not to touch it if it's possible.
I  have to maintain the program and extends some specific parts.
It seems not a good idea to have to rewrite a code because i want to 
retrofit a class.

The fact that NavigableSet inherits from SortedSet prevents me to 
retrofit my class
without changing some other parts of the program.

Rémi Forax



More information about the Concurrency-interest mailing list