I have interfaces for virtually ( ) all classes I use; for example IThread.h, IMutex.h, IConditionVariable.h, IThreadPool.h, ISynchronizationFactory.h, etc.. and then .h/.cpp "-impl" versions of them. I use factory classes to create/destroy the implementations and then just pass around and work through the interfaces.
- I do it because I find it clean/pleasant to work with, but quite some code I see do not use it. My question is why? Is it just a matter of taste? I know virtual methods adds an additional overhead, but besides that?
- In my factory classes I do not generally need dynamic class instantiation; for example I just have one "ThreadImpl" for win32/android, so I really could just have it return the ThreadImpl", but I prefer to work through an interface. Is it just a matter of preference or any practical reasons to chose one over the other?