Juan-Carlos Gandhi (
juan_gandhi) wrote2010-01-14 04:48 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
toJSON on par with toString
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
no subject
no subject
We have "extension methods" in python, in scala, in javascript...
no subject
no subject
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
no subject
no subject
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
no subject
no subject
no subject
no subject