-september.org> ddeaddf9   
   From: pasa@lib.hu   
      
   On 1/24/2013 8:23 AM, Tobias Müller wrote:   
   > Ian Collins wrote:   
   >> I don't like making extra work for myself. Maybe this stems form most   
   >> of my work being one layer above the operating system APIs, so I end up   
   >> mocking (often an automated process) a significant number of system   
   >> libraries.   
   >>   
   >> I'm still waiting (but not holding my breath) for a real world example   
   >> of why it's much easier to substitute the real code with the mock when   
   >> using DI.   
   >   
   > System calls are a good example. They are not really singletons, but the   
   > same problems apply.   
      
   And this leads to full collapse of the singleton-bashing and DI-promotion.   
      
   As following the arguments we should abandon the use of most free   
   functions ans function-based APIs. Directly. Instead fill all our   
   classes with pointers to those functions and use only those pointers for   
   calls.   
      
   > So consider a unit test with where malloc or new deliberately fails at some   
   > point.   
   > In the case of not using DI (read "Allocators") the unittest itself cannot   
   > dynamically allocate memory without failing or having side effects on the   
   > actual test.   
      
   Well, a plenty of people already demonstrated that this is NOT TRUE, but   
   the rest just keep repeating the false claim. :(   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|