Is it important for reflection-based serialization maintain consistent field ordering?
- by Matchlighter
I just finished writing a packet builder that dynamically loads data into a data stream for eventual network transmission. Each builder operates by finding fields in a given class (and its superclasses) that are marked with a @data annotation.
When I finishing my implementation, I remembered that getFields() does not return results in any specific order.
Should reflection-based methods for serializing arbitrary data (like my packets) attempt to preserve a specific field ordering (such as alphabetical), and if so, how?