noodle-head said:
In certain circumstances I would agree that the class should be
refactored.
However, there are times even in a small class were the addition of a few
extra attributes or operations on a drawing confuse more than clarify the
intent of the design. This just happens to be one of those cases.
I agree. I've been wishing for "transparent delegation" in C# recently. I'd
like to be able to delegate the implementation of an interface to a
contained object which implements it - but without manually writing the
delegations:
public interface IFacet1
{
void DoFacet1();
}
public interface IFacet2
{
void DoFacet2();
}
public class LargerClass : IFacet1, IFacet2
{
private class CFacet1 : IFacet1
{
private void DoFacet1(){};
}
private class CFacet2 : IFacet2
{
private void DoFacet2(){};
}
private CFacet1 _cFacet1 implements IFacet1;
private CFacet2 _cFacet2 implements IFacet2;
public LargetClass()
{
_cFacet1 = new CFacet1();
_cFacet2 = new CFacet2();
}
}
No need to implement
private void DoFacet1()
{
_cFacet1.DoFacet1();
}
in LargerClass.
Oh, well, dreaming.
John Saunders