Здравствуйте, Сергей Губанов, Вы писали:
СГ>А что мешает писать так:
Там не всё так просто. класс B в свою осередь реализует другие не мои интерфейсы. Если по-подробнее то так
interface IOwfulInmterface
{
int MethodWithOwfulSignature(owful_parameters)
}
class VeryGoodClass1
{
public:
int MethodWithUnderstandableParameters(understandable_parameters);
}
class VeryGoodClass2
{
public:
int MethodWithUnderstandableParameters(understandable_parameters);
}
class VeryGoodClass3
{
public:
int MethodWithUnderstandableParameters(understandable_parameters);
}
template <typename T>
class Proxy : public T, public IOwfulInterface
{
public:
int MethodWithOwfulSignature(owful_parameters)
{
MethodWithUnderstandableParameters(understandable_parameters);
}
}
и соответсвенно
interface IOwfulInterface
{
int MethodWithOwfulSignature(owful_parameters);
}
interface IVeryGood
{
int MethodWithUnderstandableParameters(understandable_parameters);
}
public class VeryGoodBase : IOwfulInterface
{
public int MethodWithOwfulSignature()
{
((IVeryGood)this).MethodWithUnderstandableParameters(understandable_parameters);
}
}
public class VeryGood1 : VeryGoodBase, IVeryGood
{
public int MethodWithUnderstandableParameters(understandable_parameters);
}
public class VeryGood2 : VeryGoodBase, IVeryGood
{
public int MethodWithUnderstandableParameters(understandable_parameters);
}
public class VeryGood3 : VeryGoodBase, IVeryGood
{
public int MethodWithUnderstandableParameters(understandable_parameters);
}
Внутри Proxy/VeryGoodBase::MethodWithOwfulSignature очень много общей логики.
То что ты написал это тоже хорошо, но интерфесов IVeryGood на самом деле несколько и не все их них всегда реализуются.
К тому же основная проблема для меня в том, что все проверки уходят в run-time и я понятия не имею реализовал ли класс-потомок всё что от него хотел базовый класс пока сам это ручками не проверю или пока не прогоняю тест, а он обширный и это просто неудобно.