Which in turn comes from Bertrand Meyer, who probably stole it from somebody else in 1990. Code should act or decide, but not both.
Re:Unit Testing is Overrated (2020)
by jesterman81 on Thursday April 07, 2022 @08:22PM
(#30951939)
This!
The design of those classes is bad, and the perceived need to reach for mocks (or interfaces) is telling you that.
The next step the author takes is to go for interfaces. That's not what I'd do. Instead, I'd decouple network from calculation with intermediate dumb data structures. The network side produces the data structure and the calculation side consumes it. The network side can further be broken down with a transformation of the API call result into the dumb data structure used for calculations.
This idea comes from an old Bob Martin presentation [1]. The whole thing is worth watching to put it into context.
This is the kind of thing that never seems to get discussed in these pieces praising integration tests over unit tests. For even better results, ditch the classes altogether and just use functions. It's quite surprising how badly designs come off the rails with the "everything is a class" model.
[1] https://www.youtube.com/watch?v=WpkDN78P884