34 ms·
If you're just treating a object as a map of keys to values, then it can be fairly transparent, but unless you're using a language like Javascript, where maps a
by weavejester 13y ago
If you're just treating a object as a map of keys to values, then it can be fairly transparent, but unless you're using a language like Javascript, where maps and objects are synonymous, objects are much more difficult to work with. It's hard to transverse them, or to merge them, or often even to look up a list of keys.
I'd suggest that a better solution would be to just use maps, at least in languages with good support for raw data structures.
- jbooth 13y ago"It's hard to transverse them, or to merge them, or often even to look up a list of keys." That's exactly what I'm arguing against in my comment on making your important structs/objects and their relationships explicit. Randomly mutating them together all over your program might seem more flexible but at a cost of making you worry about your code rather than your data definitions. And that's without even getting into performance implications. If you actually need a Map, of course, that's a different situation than the ones I'm thinking.
- weavejester 13y agoUsing a map doesn't necessarily mean random mutation, or giving up on your type system. In languages with immutable data structures and a sophisticated type system, you can type-check the keys and values in a map.