Let's say we have
public interface ITimestampProvider { DateTime GetTimestamp(); } and a class which consumes it
public class Timestamped { private ITimestampProvider _timestampProvider public Timestamped(ITimestampProvider timestampProvider) { // arg null check _timestampProvider = timestampProvider; } public DateTime Timestamp { get; private set; } public void Stamp() { this.Timestamp = _timestampProvider.GetTimestamp(); } } and a default implementation of:
public sealed class SystemTimestampProvider : ITimestampProvider { public DateTime GetTimestamp() { return DateTime.Now; } } Is it helpful or harfmful to introduce this constructor?
public Timestamped() : this(new SystemTimestampProvider()) {} This is a general question, i.e. timestamping is not the interesting part.