3 ms·
When marshaling classes in and out of xml/json decarators can be added to properties to change the name of the equivalent Json field value as well as indicating
by mmargerum 9y ago
When marshaling classes in and out of xml/json decarators can be added to properties to change the name of the equivalent Json field value as well as indicating if it's optional or not. Orms use decators to map object to relational tables the may have different field names, expressing key values, etc
- abritinthebay 9y agoNone of that sounds particularly hard, complex, or tricky without decorators though. Like, I get they can be used for stuff but why are they a better option? So far - based on the responses here - it appears to be syntax for syntax sake and no practical benefit.
- mmargerum 9y agoIt's just sugar but it's less code and I find it easy to read at least in go.
- abritinthebay 9y agoIt’s not really less code though. It’s about the same but with an syntax that obfuscates where the logic happens. Terse at the usage point yes, but it swaps clarity for brevity. A sometimes useful trade off to be sure but... not sure I’ve seen any demonstration of benefits here.