vendredi 29 mai 2015

Refactoring a concrete method in abstract class which contains an abstract method

Considering the below code,

abstract class AbstractClass
{
 public abstract void AbstractMethodA();
 public void ConcreteMethodA()
 {
  //Some operation
  ConcreteMethodB();
 }
}

 public void ConcreteMethodB()
 {
  //Huge code unrelated to this class
  AbstractMethodA();
 }
}

class DerivedClass : AbstractClass
{
public void AbstractMethodA()
{
//Some operation
}
}

Now I wish to move ConcreteMethodB() to separate class and make a call to this from the method ConcreteMethodA() in abstract class. But since ConcreteMethodB() uses an abstract method AbstractMethodA() implemented in DerivedClass, I am unable to access the method AbstractMethodA() from the new class? Any idea on how to resolve this?

Aucun commentaire:

Enregistrer un commentaire