2 ms·
At work I'm the guy who's always saying that overuse of dictionaries is a code smell. What keys does the dictionary "person_data" have? Well, originally it onl
by Scarblac 11y ago
At work I'm the guy who's always saying that overuse of dictionaries is a code smell.
What keys does the dictionary "person_data" have? Well, originally it only contained username and email address, later we added street address (everywhere where it was used, we think). And then came preferred language, but that was only added in the functions that care about that. And so on, and so forth...
Eventually all functions work with a slightly different version of a person_data dict, you're never quite sure which one a given function expects, and there is no central definition. Death by duck typing.
Dicts are for algorithms, they shouldn't be the go-to tool for structs of data. That's what classes and namedtuples are for.