Thanks for reading and valuable suggestions! I am deviding your comment into two parts
1. Abstract class implement interface
2. Extend abstract class in each state class with right implementation
Let's take an example
public interface Foo {
bool bar();
}
// Here point 1. Implementd, any ways as per my knowledge we can't implement interface method in abstract class, we can use signature only, to highlight contract with interface method
public abstract class FooBar : Foo{
public abstract bool bar();
}
//Here point 2.extend abstract class into different concrete classes, it works but still we have to use if else or switch to check exact state at that time. Here state pattern makes life easy.
public class FooBarConcreteSuccess: FooBar {
public override bool bar() {
return true;
}
}
public class FooBarConcreteFailure: FooBar {
public override bool bar() {
return false;
}
}
Please have a look on this, welcome your thoughts and suggestions. It's good to me, here from you!