|
|
|
|
|
by christophilus
1569 days ago
|
|
> how do you know which members of the struct really need to be populated 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. |
|
So then it might be better for the function to declare its own interface with just the methods it uses? But then, all the callers need to be changed if you decide to call another method.
There's no principled solution to predicting what dependencies code might need someday. It's a matter of taste.