Open andreacalia opened 4 years ago
I fully agree that the Java API is cumbersome ... but I'm wondering, should we use this for anything else than tests - and even there? Sure, Java serialization is convenient, but as far as I know it is discouraged to use it for persistent storage, because it is not guaranteed that future versions will be backwards compatible (and changes to the objects serialized break it as well). Also, it is a very opaque binary file format, so it is not easy to tell what is in such a file, and Git may not do well with it :-)
So I'm wondering ... shouldn't we rather try to use gson to serialize pure "data" objects, when possible? Sure that's more work initially, but wouldn't it be more maintainable on the longer term? (Maybe we could create another project, like ossgang-testing, which would depend e.g. on gson and could use either gson or Java Serialization through a common API?)
Happy Easter!
Often in our tests we want to create serialized version of some inputs or results of a real call to test/mock (e.g. LSA optics or settings). Dealing with standard serialization Java API for file reading is very cumbersome and prone to errors... we could have a simple and flexible API for the easy cases (write and read from classpath).
Another open question is if we can (or should) get around the fact that every object needs to extend
Serializable
. Probably is a good idea to keep it but to be discussed :slightly_smiling_face:As a starting point I paste here some code extracted from my latest attempt. To be improved (and re-designed) a lot !