In "A Case for Mock Turtles" is a pretty simple example of defining
an interface for your dependency. But what if my class has data
members of my dependency? You can't declare data members of an abstract
class.
I can make my class a template and
resolve the data member on instantiation of the class. So during tests I
can instantiate with the mock class, and during production I can
instantiate with the real class. I can use the "real" class as a default
template parameter so it doesn't muck up my API.
But
this seems to mean I have to use a lot of dynamic casting on my data
members if I want code completion. And all of this feels funny to me.
Am I going down the right path here?