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-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 : > On 24/06/10 20:53, [email protected] wrote: >> H i Ben, this discussion stopped without a result. What are your >> next steps ? > > No, it stopped with the result that my propo

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-24 Thread Ben Caradoc-Davies
On 24/06/10 20:53, [email protected] 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-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. -- ThinkGe

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 collectio

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 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 inter

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

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 tha

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 are

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Ian Turton
On Tue, Jun 15, 2010 at 10:35 AM, Mª®k 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 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: http://p.sf.net/s

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 ha

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 an

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 pr

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 >

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 w

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-15 Thread Andrea Aime
Ben Caradoc-Davies ha scritto: > 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

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 mo

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 Andrea Aime
Ben Caradoc-Davies ha scritto: > [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 Linked

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-14 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 Zimmer

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-14 Thread Ben Caradoc-Davies
On 15/06/10 14:11, Jody Garnett wrote: > One thing to do Ben is to check the project developers guide; and > perhaps copy your rant in as a project guideline. I was hoping to run it by the community before promulgating it as official policy. ;-) -- Ben Caradoc-Davies Software Engineering Team

Re: [Geotools-devel] HashMap Considered Harmful

2010-06-14 Thread Jody Garnett
One thing to do Ben is to check the project developers guide; and perhaps copy your rant in as a project guideline. Jody On Tue, Jun 15, 2010 at 3:53 PM, Ben Caradoc-Davies wrote: > On 15/06/10 13:25, Jody Garnett wrote: >> >> Can we arrange for maven to yell at us when HashMap is used? > > I do

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 no

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 1

[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 put