|
|
|
|
|
by skybrian
1569 days ago
|
|
It's not terrible to have one big struct, but sometimes it can inhibit the reuse of components in more than one system. When you call a function that takes this struct as an argument, how do you know which members of the struct really need to be populated? Its dependencies aren't clearly documented. (They are over-specified. It's like a function with many unused arguments.) If a subsystem only uses some members of the struct and you want to enforce that, maybe you pass in a smaller struct, or pass the struct members as separate arguments. This is something you'll likely have to do if you want to extract a library for other people to use. Libraries are used in multiple systems, which might or might not have their own big struct. |
|
Interfaces + duck typing? Your function shouldn’t ask for the struct, but rather for an interface describing what it needs.
Practically, though, I often just ask for the struct because I’m a slob.