From: Erik V. <eri...@xs...> - 2012-09-03 15:01:57
|
Stefan, I do not want to have a big argument over these matters, that's not worth it, but I'm trying to understand the reasoning behind your 'natural order', and I cannot find it. > You can call this reverted, but your proposal is symmetric: > Take the indexInCompany as the default Comparator and create the Player > portfolios with the a Comparator based on the order of president and > certificate type. > > As soon as you want support two (or more) different sortings you need one > (or more) "non-natural" Comparator(s). But what is then the use case of your 'natural order'? Let's look at the most obvious use cases: 1. Initial purchase from IPO. Fixed order, as configured. This usage calls for a List. 2. Purchase from Pool or Treasury. In most cases, just one share can be bought, so all you need is a single (any) share per share size. Any ordering can handle this, though a Map per share type (size) would help, or a Set per share type. Is that what you do? Current code just iterates over all shares, and any iterable collection type can handle this equally well, though a List looks most efficient. Order doesn't matter at all. 3. Finding which and how many shares can be sold. Here you need counts of each share type (size). Basically what I said for use case 2 applies here too. 4. Add up share worth. Again, any iterable collection can handle this. Nowhere I can find any reason to have such a thing as your 'natural order'. So I'm curious what use case you think would benefit from such an order. I must be missing some point... (Of course it's possible that you have explained it in the past perfectly well, and then I apologize for having forgotten it). Erik. |