php - Pattern to abstract serialization\deserialization details from data classes -
in current php project have number of classes pure data-classes, similar called poco in c# world (i omit getters\setters now):
class myentity { public $id; public $name; }
i need serialize\deserialize such entities in different formats (for example, to/from json , xml) , keep serialization detailes out of classes itself.
for deserialization builder pattern seems choice, i'm not sure serialization. suppose i'm missing obvious here.
sounds strategy pattern me. define common interface , implement various serialization strategies. invoke based on context.
Comments
Post a Comment