Re: [Geotools-devel] HashMap Considered Harmful

2010-06-25 Thread christian . mueller
Ben I will try to assist. A soon you make I patch I will check on other sdks. Quoting Ben Caradoc-Davies ben.caradoc-dav...@csiro.au: On 24/06/10 20:53, christian.muel...@nvoe.at wrote: H i Ben, this discussion stopped without a result. What are your next steps ? No, it stopped with the

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-25 Thread Gabriel Roldan
My next step will be to submit bug fixes for the most egregious HashMap assumptions, referring to this discussion. looks like the right thing to do imho. Cheers! Gabriel -- ThinkGeek and WIRED's GeekDad team up for

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-24 Thread christian . mueller
H i Ben, this discussion stopped without a result. What are your next steps ? This message was sent using IMP, the Internet Messaging Program. --

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-24 Thread Ben Caradoc-Davies
On 24/06/10 20:53, christian.muel...@nvoe.at wrote: H i Ben, this discussion stopped without a result. What are your next steps ? No, it stopped with the result that my proposal to avoid HashMap was rejected. Blame has been fairly laid at the feet of anyone who expects stable iteration order

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Rob Atkinson
Nothing wrong with HashMap - not a weakness - its behaviour is implicit in the hashing algorithm. Its simply using the wrong tool for a job :-) The problem with observation is you see what you want to see, Grasshopper :-) Modern programmers learn about frameworks - old fashioned ones with

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Andrea Aime
Jody Garnett ha scritto: Can we arrange for maven to yell at us when HashMap is used? Ben I have been known to use a couple of the other Map implementations; such as ConcurrentHashMap (and we also have our own WeakHashMap) - we may need to check if these implementations suffer the same

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Ben Caradoc-Davies
On 15/06/10 15:50, Andrea Aime wrote: Developer depending on hashmap order - chaos It's not the fault of poor hashmap that developers use it in a number of places where it's unnecessary if not even harmful. But the poor developers cannot know if they are getting a HashMap if they are a

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Ben Caradoc-Davies
On 15/06/10 16:17, Andrea Aime wrote: I still see an incompetent developer in action there. You look at that interface, you get a Map, so you know: - the API designer decided the iteration order was not important - the iteration order cannot be trusted Many other Map implementations have

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Andrea Aime
Ben Caradoc-Davies ha scritto: On 15/06/10 16:17, Andrea Aime wrote: I still see an incompetent developer in action there. You look at that interface, you get a Map, so you know: - the API designer decided the iteration order was not important - the iteration order cannot be trusted Many

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Ben Caradoc-Davies
On 15/06/10 16:45, Andrea Aime wrote: I would not blame Alice for Bob lack of skill (or simple oversight). She exposed a Map and made no promises on ordering, Bob took it and promised what he could not deliver. How does finger pointing between Alice and Bob help Carol? A bit of defensive

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Andrea Aime
Ben Caradoc-Davies ha scritto: On 15/06/10 16:45, Andrea Aime wrote: I would not blame Alice for Bob lack of skill (or simple oversight). She exposed a Map and made no promises on ordering, Bob took it and promised what he could not deliver. How does finger pointing between Alice and Bob

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread christian . mueller
I think like Andrea, filling an ordered collection from an unordered one needs an explicit ordering criteria, otherwise it is nonsense. There is nothing bad about using a HashMap, a set has an exact definition as we all know from mathematics in school (I hope so :-)) Unfortunately, as we

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Mª®k
+1 for Andrea and Christian. -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win:

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Ian Turton
On Tue, Jun 15, 2010 at 10:35 AM, Mª®k mc.pr...@gmail.com wrote: +1 for Andrea and Christian. +1 from me too - When I learnt about maps and lists I was taught they do different things and to be clear about which I needed. Ian -- Ian Turton

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Justin Deoliveira
I have to add my +1 as well. We have run up against this before when we started supporting java 6 and the moral of the story was that it is up to the downstream developer to ensure that if they are iterating through a map in a case where order matters then the onus is on them to ensure they

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread lim goh
+1 to good discussion here. Good read for me. I think I agree with how developers should really know what they are doing. I bet we all have experienced times where we wish people using our functions use them properly. However, I think Ben still has a point in being DEFENSIVE. I agree with Ben

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Gabriel Roldan
On 6/15/10 3:56 PM, lim goh wrote: +1 to good discussion here. Good read for me. I think I agree with how developers should really know what they are doing. I bet we all have experienced times where we wish people using our functions use them properly. However, I think Ben still has a point

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread lim goh
I guess we fell back to the definition of defensive, I don't know a good replacement word for it, but what I wanted to say is: 1. Using Map as a return type is completely valid, good, should, defensive... 2. Consumer who expects specific implementation detail is wrong, bad, should not. 3. The

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Ben Caradoc-Davies
On 16/06/10 03:49, Gabriel Roldan wrote: So, being certain that most probably I introduced some of this problems myself by having worked on the app-schema code years ago, I still strongly argument against anyone that expects a given iteration order out of a method returning a Map Gabriel,

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread christian . mueller
Ben is right here. The problem is spread over all geotools/geoserver tests. As I started with geotools/IBM SDK I fixed a lot of tests having this problem. At the moment, there are some tests which are not easy to fix for me. I am not sure if the library should pass back an ordered

[Geotools-devel] HashMap Considered Harmful

2010-06-14 Thread Ben Caradoc-Davies
[This affects GeoServer too, but I'd rather avoid a cross-list post.] Synopsis: - HashMap has platform-dependent iteration order. - Use LinkedHashMap to make iteration order consistent across platforms. - Same rule applies for HashSet: replace with LinkedHashSet. HashMap uses key hashCodes to

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-14 Thread Jody Garnett
Can we arrange for maven to yell at us when HashMap is used? Ben I have been known to use a couple of the other Map implementations; such as ConcurrentHashMap (and we also have our own WeakHashMap) - we may need to check if these implementations suffer the same weaknesses as HashMap. Jody On

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-14 Thread Ben Caradoc-Davies
On 15/06/10 13:25, Jody Garnett wrote: Can we arrange for maven to yell at us when HashMap is used? I do not think we should do this ,as there are legitimate occasions where HashMap may be used for performance, particularly when we have many insertions, one iteration, and iteration order is