From: Stefan F. <ste...@we...> - 2012-02-07 18:40:36
|
All: further update about the progress on Rails2.0 (if anyone follows that already). This update added new Portfolio and Wallet classes which are based on the general State class. Overall Status: The state package should now be close to feature complete, however expect frequent updates and fixes. The model package now contains a lot of classes and interfaces (everything around Owner...) which will be removed eventually. Next step is removing remaining errors and bugs. After this the Context/Item setup will be implemented throughout Rails. Stefan More details: As I was not convinced by my previous refactoring of the Portfolio and Ownership approach, I did a fresh start there. For this I decided to create a basic Portfolio class that is a first class child of State. It is currently called PortfolioNG, however will be renamed to Portfolio later on. It allows storing of OwnableItem(s) and is basically a thin wrapper around an ArrayListMultimap. However it ensures that adding to a portfolio always remove the item from its previous portfolio. The map keys have to implement the new Interface ItemType. An example with Train objects will make this clear: A portfolio will be defined as Portfolio<Train> portfolio = Portfolio.create("Trains"); Then a train object train can be moved into that portfolio using portfolio.moveInto(train); and will be automatically removed from the previous owning portfolio. For trains the TrainType will be the key that is used in the portfolio so one can use portfolio.getItems(trainType); to retrieve all trains from the portfolio that belong to the specified trainType. In parallel there is a Wallet class which is another subclass of State which can store CountableItem(s). Again this is a thin wrapper this time around HashMultiset. This works with a similar syntax, but it allows to store resources that comes in (integer) multiples, e.g. money. In principle it could also be used (in the longer run) for all objects (shares, tiles and even trains), where the individual items only differ in respect with to the owner. For reference for the Collection types discussed above please refer to the collections of the Guava library (aka Google Collections). See http://code.google.com/p/guava-libraries/wiki/NewCollectionTypesExplained |