質問

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top