toJSON on par with toString
Jan. 14th, 2010 04:48 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I've been thinking lately... say, you are writing a pojo, and it is a good practice to have a good toString(), right? How about toJSON/fromJSON? seems like it would be a good idea to have it everywhere as well, what do you think?
no subject
Date: 2010-01-15 02:31 am (UTC)no subject
Date: 2010-01-15 03:00 am (UTC)no subject
Date: 2010-01-15 03:02 am (UTC)We have "extension methods" in python, in scala, in javascript...
no subject
Date: 2010-01-15 11:26 am (UTC)no subject
Date: 2010-01-15 05:52 am (UTC)afaik they have some special attributes applied to them, so i can search for them, but i wonder if this functionality is available through the usual means
no subject
Date: 2010-01-15 11:04 am (UTC)no subject
Date: 2010-01-15 11:10 am (UTC)no subject
Date: 2010-01-15 11:20 am (UTC)There are several workarounds tho, but they depend on your particular business logic. E.g. you could hardcode namespaces to look extension methods in (via compile-time constants or via configuration). Another option would be reading PDBs and acquiring namespace info for the method you wish (tho this won't work for release builds). Well, you get the idea - all solutions to this problem are hacks that work only under certain circumstances.
Btw, because of this particular glitch DLR doesn't support extension methods.
no subject
Date: 2010-01-15 11:23 am (UTC)no subject
Date: 2010-01-15 11:33 am (UTC)no subject
Date: 2010-01-15 02:54 pm (UTC)no subject
Date: 2010-01-16 12:47 am (UTC)no subject
Date: 2010-01-15 03:28 am (UTC)