E.g.
public abstract class Foo
{
public Bar f1()
{
return new Bar();
}
}
and
public class Bar extends Foo
{
}
From the design point of view, do you agree this design is anti-pattern?
Yes.
The reason it's bad is because it breaks encapsulation. If someone changes Foo
, they realize they could be changing all subclasses. If someone changes Bar
, they should never have to think about changing its super classes; its super classes should work the same regardless of the content of Bar
.