> Jody Garnett a écrit :
>> I am not sure I like backwards compatibility over consistency. Ie if 
>> we are going to break people let's at least do it with a usability 
>> goal in mind.
>>
>> The other alternative is:
>>
>> GeoTools 2.5.x:
>> - getRulesArray() - returns an array
>> - getRules() - deprecated
>>
>> GeoTools 2.6.x
>> - getRulesArray() - returns getRules().toArray( new Rule[0] );
>> - getRules() - return a List

I'm not well aware of the roadmap for styling, so my words may not be 
pertinent. 
But as far as consistency is concerned in names of methods returning a 
collection, I think that it depends if the collection is intented to be "live" 
or immutable.

Immutable collections
---------------------
List<Foo> getRules(); // Returns an immutable list

void setRules(List<Foo>); // *Copy* the content of this list.


Live collections
----------------
List<Foo> rules();  // Returns a *mutable* collection.

*No* setters. For setting all rules, use the following idiom:

rules().clear();
rules.addAll(rules);


The former is consistent with Java beans pattern The later is consistent with 
Java collection framework usage:

http://java.sun.com/javase/6/docs/api/java/util/Map.html#values()
http://java.sun.com/javase/6/docs/api/java/util/List.html#subList(int,%20int)
http://java.sun.com/javase/6/docs/api/java/util/SortedSet.html#headSet(E)

and more. I didn't included in this list similar methods (Map.keySet(), 
Map.entrySet(), SortedSet.tailSet(E), etc.)


So in short the question is: do you want to follow Java Beans pattern or Java 
collection framework pattern?

Java beans pattern may be slightly easier to implement. Java collection 
framework pattern is more powerful.

My personal preference would be for the Java collection framework pattern 
because it leads to slightly smaller API will being both more performant (less 
copies) and more flexible (can change the content using all Java collection 
methods), at the cost of slightly more complexity on implementor side (but this 
is invisible to users).

        Martin

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to