Subject: | Using an array to implement this class binds subclasses tightly. |
Using an array with constant indexes to implement this class tightly
binds subclasses that need to store data. For instance, if a subclss
chooses indexes 11 & 12 for data storage, and additional data is later
added to T::P in the same indexes, then the released versions of the
subclass will not work with the new T::P and new versions of the
subclass will not work with old versions of T::P (barring a
version->index table in the subclass which will need to be updated with
each T::P release).
The simple fix for this would be to export a hash (for instance
%Time::Piece::Fields) relating keys to indexes, or even a simple scalar
max index (e.g. $Time::Piece::MaxIndex), rather than implementing the
array indexes with constants. This way, subclasses can store their data
at $Time::Piece::MaxIndex + 1 .. X, for instance, and have no fear of
being incompatible with newer versions of T::P due to data storage.