Closed lmolkova closed 5 years ago
E.g. ITraceComponent
public interface ITraceComponent
{
ITracer Tracer { get; }
IPropagationComponent PropagationComponent { get; }
IClock Clock { get; }
IExportComponent ExportComponent { get; }
ITraceConfig TraceConfig { get; }
}
public abstract class TraceComponentBase : ITraceComponent
{
internal static ITraceComponent NewNoopTraceComponent => new NoopTraceComponent();
public abstract ITracer Tracer { get; }
public abstract IPropagationComponent PropagationComponent { get; }
public abstract IClock Clock { get; }
public abstract IExportComponent ExportComponent { get; }
public abstract ITraceConfig TraceConfig { get; }
}
There is no visible benefit in having both of them and interface could be removed. For testing purpose virtual methods are as mockable as interfaces.
There could be a case when base class is heavy and requires some additional assembly references - in this case it makes sense to provide an interface
This will be handled in OpenTelemetry project
C# and .NET programming styles do not typically involve interface-for-everything approach.
We should have a discussion about it in opencensus and during separation of API and Impl (#8) ensure that interfaces are not overused