In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but one answer suggested using conditional compilation, retaining static binding in the production code.  This answer was modded -2 at the time of reading, so at least 2 people really thought this was a wrong answer.  Perhaps misuse of DEBUG was the reason, or perhaps use of fixed value instead of more extensive validation.  But I can't help wondering:

Is the use of conditional compilation an inappropriate technique for implementing unit test stubs?  Sometimes?  Always?

Thanks.

Edit-add:  I'd like to add an example as a though experiment:

class Foo {
    public Foo() { .. }
    private DateTime Now { 
      get {
#if UNITTEST_Foo
        return Stub_DateTime.Now;
#else
        return DateTime.Now;
#endif
      }
    }
    // .. rest of Foo members
}


comparing to

interface IDateTimeStrategy { 
    DateTime Now { get; }
}
class ProductionDateTimeStrategy : IDateTimeStrategy {
  public DateTime Now { get { return DateTime.Now; } }
}
class Foo {
    public Foo() : Foo(new ProductionDateTimeStrategy()) {}
    public Foo(IDateTimeStrategy s) { datetimeStrategy = s; .. }
    private IDateTime_Strategy datetimeStrategy;
    private DateTime Now { get { return datetimeStrategy.Now; } }
}


Which allows the outgoing dependency on "DateTime.Now" to be stubbed through a C# interface.  However, we've now added a dynamic dispatch call where static would suffice, the object is larger even in the production version, and we've added a new failure path for Foo's constructor (allocation can fail).  

Am I worrying about nothing here?  Thanks for the feedback so far!


Question: Powering circuit from PC's USB port
Answer: The XX1117 is not really an LDO regulator, more of a medium-drop-out. 

You need to give it quite a bit more input voltage than you expect out of it. So if your circuitry is happy with 3V (say), you may be okay. You can only count on 4.35V at the USB connector, and the regulator can use as much as 1.3V depending on current etc. so that leaves you with 3.05V. At 80mA, 3.3V may be acceptable, but you'll have to sharpen your pencil to figure that out. 

If you want to create a low-noise well-regulated 5V supply from a USB input, you would have to boost the input to something like 5.5V and use a true LDO or to more like 6.5V and use an XX1117 regulator. At 80% efficiency that means you'd be at about 150mA input current. That's acceptable, but you're supposed to negotiate for current above 100mA. Possibly the FTDI chip does that for you. If you're dealing with two supply voltages in your system you may have to have voltage translators and so on, and the details will vary a lot depending on exactly what you are trying to accomplish. 

Maybe you can operate all the digital stuff from the USB Vcc and use regulated 3.0V or 3.3V for the analog stuff. That would be my first plan of attack.