tags:

views:

56

answers:

1

Consider the following:

public interface ICleanCoder
{
    void DoSomeCoding(object task);
}

public interface ICleanCoder<T>
{
    void DoSomeCoding(T task);
}

...

public class TestCleanCoding
{
    void RegisterCleanCoder(ICleanCoder coder);
}

I have to have the initial non generic interface to enable a non generic reference to it later on. I know that technically that makes perfect sense, but the solution smells a little rotten to me, and I was wondering if I was missing something.

+2  A: 

Unfortunately, that's the only way to do this, unless you want to make TestCleanCoding a template too (which is a reasonable design decision and won't throw away the benefits of ICleanCoder being a template); also, you're leaving out an important part:

public interface ICleanCoder<T> : ICleanCoder
{
    void DoSomeCoding(T task);
}

Otherwise, your templated interface is unrelated to your base interface.

Paul Betts