3 ms·
Most things here are reasonable, but I don't see a point about having only one struct. If your state is better organized in lots of hierarchical structs, within
by vortico 8y ago
Most things here are reasonable, but I don't see a point about having only one struct. If your state is better organized in lots of hierarchical structs, within lists, within other structs, your data will be easier to move around, copy, and zero in smaller chunks, and you can write functions which processes isolated segments of data rather than a huge global state.
- matthiasv 8y agoThe point was about the user-facing side not the internal representation of state.
- vortico 8y agoEven then, it seems weird to prefer a big flat state rather than a state made of heirarchical sub-structures and arrays.
- yason 8y agoAs the user of the library I probably don't care about the hierarchies. If I want X the library can provide me a function to get X by looking up its internal substructures and arrays so that I don't have to.
- deleted 8y ago[deleted]
- enriquto 8y agoThis is very sound advice. The interface of the library is intended to help the user of the library, not the developer of the library. The simplest interface is the best for the user, who does not want to know anything about the implementation details. In the ideal case, the developer and the api designer will be different persons who are not in good terms to each other. The more the developer hates the api designer, the better.