I have been practicing this hybrid approach for dependency injection in the last couple of days and I am wondering if it should also apply to components which are within the same package?
I have a GPIO module that uses the device chip and that required to be mocked for unit testing. I also exposed its Pins as interfaces, so their consumers would not have any coupling.
I have a Motor component that lives in another package and consumes the GPIO Pins' interfaces.
Then a ControlAgent component that lives within the same package as the Motor component, and consumes it.
One benefit of using an interface for the Motor and a template class for its implementation seems to be making its construction a
little more generic (as long as I provide what's needed at compile time), and also makes the unit testing easier.
But I also have three more components (PID/Encoder/Odometry) and potentially more that are consumed by the ControlAgent.
Seems like a big effort in development time and complexity to setup each of those as interfaces when they are part of the same package.
What is the long term benefit (if any) in the ControlAgent consuming all of its neighboring components as
std::unique_ptrs (or any pointers) to interfaces rather than friends/members?
Especially since the implementations use templates, so the types must be known at compile time.
Does the over-engineering make the implementation less readable but also more maintainable?