I'm not trying to say that there on only one right way to do things, however the basic JUMP design is a very good one, and consistency in return values for the methods of a class is not necessarily something to strive for.
In the case of getFeatures(), the main accessor method of the class, it is advertising to developers that it returns a List with all of the capabilities of a list. JUMP's developers chose not to do this for the less frequently used methods like remove() where it is less important. This is a valid choice. Other choices are also valid, providing they are thought out at the design stage of a project. Since JUMP is in the maintenance stage, it is probably not appropriate to change any interfaces in the API without a really good reason. If you use the Eclipse right-click option of References, you will find several places in the code that make use of the get(n) method of a List after using getFeatures(). If you think about it, there are naturally places in the code where order matters, and others where it does not. See Jon's comment on the query() method of FeatureDataset. regards, Larry On 5/1/07, Sunburned Surveyor <[EMAIL PROTECTED]> wrote: > This discussion has gone a lot farther than I thought it would, but it has > been interesting. I've learned some things about Collections in Java that I > had never thought about before. > > Larry wrote: "Notably it adds the important > positional access methods. Of course, Lists also have order which all > Collections do not support. Since JUMP depends on both of these > features, I believe it is correct to specify List and not Collection > since to do so would give programmers the false impression that it did > not matter which Collection was used." > > If this is the case, then the FeatureCollection.remove() method should > return a List and not a Collection, correct? I wasn't really questioning the > use of a List in my original e-mail on this thread, I was just trying to > understand why it was used as the return type for two of the methods in the > interface, but not the third. > > I still don't understand why the methods in FeatureCollection need to return > a List. I don't think the order of the returned collection of Feature > objects, or the ability to access these objects positionally would be that > critical. What seems critical to me is that the returned collection not > contain duplicates. In which situation would the order of the Feature > objects in the returned collection be important? > > I'm not trying to be argumentative. :] I want to understand why certain > decisions were made in JUMP's code base, and I want to take advantage of the > expertise more experienced Java developers like Stefan and Larry. > > Thank you in advance for your patient efforts to explain some of these basic > Java principles to me. > > The Sunburned Surveyor > > > On 5/1/07, Larry Becker <[EMAIL PROTECTED]> wrote: > > > > Stefan is correct that Lists have more methods, although technically > > Collection is an interface not a super class. The List interface is a > > superset of the Collection interface. Notably it adds the important > > positional access methods. Of course, Lists also have order which all > > Collections do not support. Since JUMP depends on both of these > > features, I believe it is correct to specify List and not Collection > > since to do so would give programmers the false impression that it did > > not matter which Collection was used. > > > > regards, > > Larry > > > > See: > http://java.sun.com/docs/books/tutorial/collections/interfaces/collection.html > > and: > http://java.sun.com/docs/books/tutorial/collections/interfaces/list.html > > > > On 5/1/07, Stefan Steiniger <[EMAIL PROTECTED]> wrote: > > > mhm.. to my knowledge the collection is the super class, thus lists have > > > more methods. > > > so you can not cast from collection to list but the other way around??? > > > > > > stefan > > > > > > Sunburned Surveyor schrieb: > > > > Stefan, > > > > > > > > I'm a little confused. A List is an implemenation of the Collection > > > > interface. I thought it would make more sense for the > FeatureCollection > > > > interface to return an implementation of Collection, rather than a > List > > > > specifically, becuase it gives the programmer implementing the > interface > > > > more flexibility. > > > > > > > > I don't think this really matters to the user of the FeatureCollection > > > > interface, as you can easily cast the returned implementation of > > > > Collection to a List if desired. > > > > > > > > I was just curious about the consistency of the FeatureCollection > > > > interface, as it had some methods that returned a generic collection, > > > > and some others that returned a List specifically. I think in > hindsight > > > > it would've been better to have all of the methods return a > Collection, > > > > as there was no specific reason why a List was returned. > > > > > > > > At any rate, Martin brought out that this isn't really a minor > problem, > > > > and not worth fixing, as it would break any existing plug-ins that > > > > expect to get a List and not a Collection. > > > > > > > > The Sunburned Surveyor > > > > > > > > On 4/30/07, *Stefan Steiniger* < [EMAIL PROTECTED] > > > > <mailto:[EMAIL PROTECTED]>> wrote: > > > > > > > > although you already respond with an ok. > > > > i just want underline what Martin said, because a list has much > more > > > > features. and i guess alsmost everybody uses these nice features? > > > > > > > > But It may be possible to add a second method - if one prefers to > get a > > > > collection :) > > > > > > > > stefan > > > > > > > > Sunburned Surveyor schrieb: > > > > > O.K. > > > > > > > > > > SS > > > > > > > > > > On 4/27/07, *Martin Davis* <[EMAIL PROTECTED] > > > > <mailto:[EMAIL PROTECTED]> > > > > > <mailto: [EMAIL PROTECTED] > > > > <mailto:[EMAIL PROTECTED]>>> wrote: > > > > > > > > > > SS, > > > > > > > > > > It's easy to change the FC interface methods return value > > > > from List to > > > > > Collection n the JUMP CVS codebase. > > > > > > > > > > But you risk breaking a lot of external plugins which have > > > > been coded to > > > > > the current interface. I don't really see a pressing need > to > > > > do this, > > > > > so I would vote against it. > > > > > > > > > > Sunburned Surveyor wrote: > > > > > > Martin, > > > > > > > > > > > > This makes perfect sense. Thank you for the > clarification. > > > > If no one > > > > > > has an objection I will make a not of it in the Javadoc > > > > API. I might > > > > > > also see if I can refactor the FeatureCollection > interface > > > > to use > > > > > > java.util.Collection on the other two methods. This will > > > > give me some > > > > > > practice with Refactoring. (I won't commit these changes > > > > to the CVS > > > > > > until I know it works and I've had a chance to talk to > the > > > > other > > > > > > developers.) > > > > > > > > > > > > SS > > > > > > > > > > > > On 4/27/07, *Martin Davis* < [EMAIL PROTECTED] > > > > <mailto:[EMAIL PROTECTED]> > > > > > <mailto: [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> > > > > > > <mailto: [EMAIL PROTECTED] > > > > <mailto:[EMAIL PROTECTED]> > > > > > <mailto:[EMAIL PROTECTED] > > > > <mailto: [EMAIL PROTECTED]>>>> wrote: > > > > > > > > > > > > The fact that getFeatures and query return a List is > > > > probably an > > > > > > undesirable widening of the API. For maximum > > > > flexibility for > > > > > > implementors, they should all return Collection. > This was > > > > > just an > > > > > > oversight in the original design. > > > > > > > > > > > > The reason that remove(Envelope) returns a > collection > > > > of the > > > > > removed > > > > > > features while the others don't is that in the other > two > > > > > methods the > > > > > > caller already knows which features are the ones > which > > > > are to be > > > > > > removed. In the case of remove(Envelope) the only > way > > > > to know > > > > > > what has > > > > > > happened is to get the method to report which > features it > > > > > removed. > > > > > > > > > > > > Sunburned Surveyor wrote: > > > > > > > I've been working on my FeatureCache and I've got > a > > > > couple of > > > > > > > questions about the FeatureCollection interface. > > > > > > > > > > > > > > Three of the methods of the interface return > > > > instances of > > > > > > > java.util.Collection. The getFeatures() method and > > > > the query() > > > > > > methods > > > > > > > return instances of java.util.List, while the > > > > remove() method > > > > > > returns > > > > > > > an instance that implements the > java.util.Collection > > > > > interface. I am > > > > > > > wondering why these three methods don't > consistently > > > > return > > > > > > instances > > > > > > > of java.util.List or instances of > > > > java.util.Collection. Why > > > > > is the > > > > > > > return value of the remove() method different from > the > > > > > other two > > > > > > methods? > > > > > > > > > > > > > > I also noted that there are three methods that > perform > > > > > removal of > > > > > > > Feature objects from the FeatureCollection, but > only > > > > one of > > > > > these > > > > > > > methods, the remove(Envelope env) method, returns > > > > the Feature > > > > > > objects > > > > > > > removed as an instance of java.util.Collection. > The > > > > > remove(Feature > > > > > > > feature) method and the removeAll(Collection > features) > > > > > method do > > > > > > not > > > > > > > return the Features removed. Is there a reason why > this > > > > > behavior is > > > > > > > not consistent? > > > > > > > > > > > > > > I'm just curious. It seems the Vivid Solutions > team > > > > always had > > > > > > reasons > > > > > > > for doing things that aren't readily apparent > > > > because of my > > > > > lack of > > > > > > > programming experience. > > > > > > > > > > > > > > Thank you an advance for any clarification. > > > > > > > > > > > > > > The Sunburned Surveyor > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > > This SF.net email is sponsored by DB2 Express > > > > > > > Download DB2 Express C - the FREE version of DB2 > express > > > > > and take > > > > > > > control of your XML. No limits. Just data. Click > to > > > > get it > > > > > now. > > > > > > > > http://sourceforge.net/powerbar/db2/ > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Jump-pilot-devel mailing list > > > > > > > > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net > > > > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net>> > > > > > > <mailto: > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net> > > > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net>>> > > > > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > <https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > > > > > > > > > > > > > > > > -- > > > > > > Martin Davis > > > > > > Senior Technical Architect > > > > > > Refractions Research, Inc. > > > > > > (250) 383-3022 > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > > > > > > > This SF.net email is sponsored by DB2 Express > > > > > > Download DB2 Express C - the FREE version of DB2 > > > > express and take > > > > > > control of your XML. No limits. Just data. Click to > > > > get it now. > > > > > > > http://sourceforge.net/powerbar/db2/ > > > > > > > _______________________________________________ > > > > > > Jump-pilot-devel mailing list > > > > > > > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net> > > > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net>> > > > > > > <mailto: > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net> > > > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net>>> > > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > > > This SF.net email is sponsored by DB2 Express > > > > > > Download DB2 Express C - the FREE version of DB2 express > > > > and take > > > > > > control of your XML. No limits. Just data. Click to get > it > > > > now. > > > > > > http://sourceforge.net/powerbar/db2/ > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > Jump-pilot-devel mailing list > > > > > > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net > > > > > > > <mailto:Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net>> > > > > > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > <https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel> > > > > > > > > > > > > > > > > -- > > > > > Martin Davis > > > > > Senior Technical Architect > > > > > Refractions Research, Inc. > > > > > (250) 383-3022 > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > > This SF.net email is sponsored by DB2 Express > > > > > Download DB2 Express C - the FREE version of DB2 express > and take > > > > > control of your XML. No limits. Just data. Click to get it > now. > > > > > http://sourceforge.net/powerbar/db2/ > > > > > <http://sourceforge.net/powerbar/db2/> > > > > > > _______________________________________________ > > > > > Jump-pilot-devel mailing list > > > > > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net> > > > > > <mailto: > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net>> > > > > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > This SF.net email is sponsored by DB2 Express > > > > > Download DB2 Express C - the FREE version of DB2 express and > take > > > > > control of your XML. No limits. Just data. Click to get it now. > > > > > http://sourceforge.net/powerbar/db2/ > > > > <http://sourceforge.net/powerbar/db2/> > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > > > _______________________________________________ > > > > > Jump-pilot-devel mailing list > > > > > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net> > > > > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > > This SF.net email is sponsored by DB2 Express > > > > Download DB2 Express C - the FREE version of DB2 express and take > > > > control of your XML. No limits. Just data. Click to get it now. > > > > http://sourceforge.net/powerbar/db2/ > > > > _______________________________________________ > > > > Jump-pilot-devel mailing list > > > > Jump-pilot-devel@lists.sourceforge.net > > > > <mailto: Jump-pilot-devel@lists.sourceforge.net> > > > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > > ------------------------------------------------------------------------- > > > > This SF.net email is sponsored by DB2 Express > > > > Download DB2 Express C - the FREE version of DB2 express and take > > > > control of your XML. No limits. Just data. Click to get it now. > > > > http://sourceforge.net/powerbar/db2/ > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > _______________________________________________ > > > > Jump-pilot-devel mailing list > > > > Jump-pilot-devel@lists.sourceforge.net > > > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by DB2 Express > > > Download DB2 Express C - the FREE version of DB2 express and take > > > control of your XML. No limits. Just data. Click to get it now. > > > http://sourceforge.net/powerbar/db2/ > > > _______________________________________________ > > > Jump-pilot-devel mailing list > > > Jump-pilot-devel@lists.sourceforge.net > > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > > > > > -- > > http://amusingprogrammer.blogspot.com/ > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Jump-pilot-devel mailing list > > Jump-pilot-devel@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > -- http://amusingprogrammer.blogspot.com/ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel