Hiya Greg,
> Nice to talk to the boss. :)
*grin* Well, I'm not the boss :P
>
> I have bought into CppUTest, and James' book, in a major way. However, I have got to say I'm not a big fan of function pointer stubbing. I'm Ok with the basic principle of it, but the idea of putting them on the server side, as a global variables, seems to fly a bit in the face of data encapsulation and SOLID design principles. I would prefer the function pointers to be private data on the client side, with the pointers installed at run time (dependency injection), through the client's API.
Yeah.. I used to think that too :)
Nowadays, I do use function pointer replacement quite a lot more when working with e.g. C library as it is so convenient (especially when using UT_PTR_SET). I just look at it as putting a *very thin* wrapper between the 3rd part and your code and try not to think them of function pointers :)
> So I am all for the loose coupling that function pointers can provide, but I think the client should be aware of the loose coupling. The onus should be on the client, not the server. Well that's what I reckon anyway. :)
Well, for function pointers, I really only use them for stubbing in tests, so really don't want them in the interface as that would complicate all code.
> Anyway, you guys rock. Really, I think it's great how you, Terry and James get right in at the coalface here, answering questions directly, and in a very timely fashion.
Oh, well, you are lucky that we are not all doing other things at the moment :P
Bas
>
> Regards,
> Greg
>
>
> On Tuesday, September 24, 2013 4:26:30 PM UTC+8, Bas Vodde wrote:
>
> Hi Greg,
>
> I personally always use function pointer stubbing for C library functionality as linked stubbing C library functionality has all kinds of site effects :)
>
> Likewise for pthreads :)
>
> Years ago I did a linked stub for pthreads library only to discover (after a day of debuggin) that the implementation of the C++ keyword throw used the pthreads library and was therefore causing an assert ;)
>
> Bas
>
>