« first day (1332 days earlier)      last day (3842 days later) » 

23:05
:-)
guys, how would you implement a DTO unserialization?
would it be a separate class or the DTO itself that does it?
According to Fowler's PoEAA DTO must be responsible for doing it by itself
But I cannot think of a good interface that would satisfy me. MyDTO::unserialize($binary) or what?
23:20
@zerkms Shouldn't DTO's be inherently serializable/unserializable through just a function. They're just made up of data with no hidden state, so you can use just a function to do them?
I do this to serialize DTO's as json data to send them to javascript.
and vice-versa.
@Danack $objectType = $jsonData[OBJECT_TYPE]; --- hehe
Yeah.....need a bit more security ;)
that's what exactly confuses me - is how unserializer infers the DTO type
and adding an explicit property is what I'd like to avoid if possible
@zerkms Possibly you're mistaking the chicken for the egg. If I have a DTO object, I can serialize it with that function. If I have the serialized version, it has encoded in the serialized string what object type it was.
The only problem would come from the database layer, which should understand what it is retrieving.
Okay, so your opinion is that there must be one universal deserializing function
23:36
@zerkms Not quite - that you start with real DTO objects, you can then perform any serialization function on them (and the inverse of that function to a DTO) - but you can have multiple serialization functions for different "serialisation targets" e.g. to Javascript, storing in cache etc.
assuming it's one "target" but multiple various DTO types
there will be one deserialization function in your solution?
Yes - DTOs are meant to be totally inspectable from outside the class, they're just a pure transport for data. So you should be able to serialize them from outside the DTO, without having to give the DTO object it's own serialize/deserialize function.
/though asking a Mr Maxell's advice would probably be sensible.
yep, thanks
user924016
23:52
nn

« first day (1332 days earlier)      last day (3842 days later) »