짧은 답변은 여기에서 먼저 블로그 게시물을 작성하려고합니다. 아이디어를 제공해 주셔서 감사합니다! 우리가 직접 회원을 변환 할 필요가 간접적으로 용도, 즉 필드로 자격을
class PresenterAndController
{
public void Control()
{
Present();
}
public void Present()
{
// present something
}
}
첫째 :
자, 가정하자 우리는이 있습니다. 이렇게하려면 사용 추출물 슈퍼 클래스 리팩토링은 슈퍼 클래스에 발표자 부분을 추출 :
internal class Presenter
{
public void Present()
{
// present something
}
}
class PresenterAndController : Presenter
{
public void Control()
{
Present();
}
}
한을 위임 될 PresenterAndController에 필드를 만들고 (Alt-INS)에 위임 멤버를 만들 생성 사용합니다. 그들은 동일하기 때문에, 기본 방법을 숨길 발생합니다 : 상속 목록에서
internal class Presenter
{
public void Present()
{
// present something
}
}
class PresenterAndController : Presenter
{
private Presenter myPresenter;
public void Present() // hides base method
{
myPresenter.Present();
}
public void Control()
{
Present(); // it now references method from this type
}
}
제거 발표자 당신은 분할 클래스로 수행됩니다. 이제 인터페이스를 추출하고 가능하면 기본 유형을 사용하고 그렇지 않으면 정리할 수 있습니다.
JetBrains의 우수한 도구를 사용하지 않는 한! –