I have business objects, that I would like to (de)serialize from and into a .yaml
file.
Because I want the .yaml
to be human readable, I need a certain degree of control over the serialize
and deserialize
methods.
Where should the serialization logic go?
A) If I teach every object, how to de/serialize itself, but that probably violates the single-responsibility-principle
.
B) If I put it inside a common serialization
module, that might violate the open-closed-principle
, since more business objects will be added in the future. Also, changes to objects need now be performed in two places.
What is the recommended approach to solve this conundrum for tiny-scale applications?
Aucun commentaire:
Enregistrer un commentaire