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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -