From: Stefan F. <ste...@we...> - 2012-09-02 21:55:04
|
The Comparator would be based on the already available indexInCompany variable in Rails1.x (which is identical to the id in Rails2.0). So you provide create a Comparator and pass that to the constructor of the IPO portfolio. So the IPO portfolio will be sorted by the purchase order, whereas the Player portfolios will be sorted by president and certificate type (which I call the natural ordering). 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). I have the strong doubt that I will not convince you, and most likely your reasons against using a Set are as good and valid as mine for not using a List (mainly to avoid undo and testing related problems). However I do not see that much difference between a list with an implicit ordering (initial IPO sequence) of unique elements and a SortedSet, except that you have to ensure the correct order by the code using the portfolio. For the sorted set you have to write code to specify the order, but after that the portfolio guarantees the ordering. Stefan On 09/02/2012 10:52 PM, Erik Vos wrote: > I would say: the natural ordering is the order in which shares are initially > sold. > I would strongly advise against meddling with that order. > For that reason, I'm not at all convinced that a Set is better than an Array > to hold the company certificates. > > Having to create a special Comparator to restore the initial order (how to > configure that?) sounds like doing it backwards to me (we Dutch call that > "putting the horses behind the carriage"). > > In special cases like the Prussian, or the SJ in 18Scan, where non-president > shares can be bought before the company floats, there is no reaI need to > have the President certificate on top, although I would still consider that > 'natural'. These cases need special code anyway. > > Also keep in mind conversions from 5-share into 10-share companies, and > other variations on that theme. > > Erik. > >> -----Original Message----- >> From: Stefan Frey [mailto:ste...@we...] >> Sent: Sunday, September 02, 2012 4:04 PM >> To: Development list for Rails: an 18xx game >> Subject: Re: [Rails-devel] Rails2.0: Portfolios, Ownable and Owner >> >> Erik: >> the underlying TreeSet allows to optionally specify a Comparator which >> deviates from the natural ordering. >> >> Thus it is easy to add a different ordering to the IPO portfolio. >> >> But thanks for reminding me of that, do you know other cases where the >> ordering of a "portfolio" in Rails 1.x is important for game mechanics? >> >> Stefan >> >> On 09/02/2012 12:41 PM, Erik Vos wrote: >>> Stefan, >>> >>>> * PublicCertificates are sorted by >>>> i) President or not >>>> ii) CertificateType (and those are sorted by number of shares inside) >>>> iii) CertificateId >>>> >>>> This keeps the PresidentShare at position zero of each portfolio >>>> without requiring any code to keep it there. And it keeps the >>>> multi-shares at the >>> top >>>> of a list of certificates. >>> >>> How will you then handle the 1835 double shares that must appear at >>> the >>> *bottom* of the IPO stack (BA, WT and HE)? >>> Currently, specification order determines IPO order. >>> >>> Erik. >>> >>> >>> ---------------------------------------------------------------------- >>> -------- >>> Live Security Virtual Conference >>> Exclusive live event will cover all the ways today's security and >>> threat landscape has changed and how IT managers can respond. >>> Discussions will include endpoint security, mobile security and the >>> latest in malware threats. >>> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >>> _______________________________________________ >>> Rails-devel mailing list >>> Rai...@li... >>> https://lists.sourceforge.net/lists/listinfo/rails-devel >>> >> >> >> > ---------------------------------------------------------------------------- > -- >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and threat >> landscape has changed and how IT managers can respond. Discussions will >> include endpoint security, mobile security and the latest in malware > threats. >> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> Rails-devel mailing list >> Rai...@li... >> https://lists.sourceforge.net/lists/listinfo/rails-devel > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > |