There's a more advanced form of the Factory Pattern which makes it easier to stay aligned with the Open Closed Principle, called the Abstract Factory Pattern: en.wikipedia.org/wiki/Abstract_fac...
However, in the implementation above, while the factory itself violates the open/closed principle, the Dialog itself doesn't and the factory aids you in adhering to it.
You implement the Dialog, thus extending it, rather than modifying it and you use the abstract to interface with the concrete implementation returned from the Factory.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There's a more advanced form of the Factory Pattern which makes it easier to stay aligned with the Open Closed Principle, called the Abstract Factory Pattern: en.wikipedia.org/wiki/Abstract_fac...
However, in the implementation above, while the factory itself violates the open/closed principle, the
Dialog
itself doesn't and the factory aids you in adhering to it.You implement the Dialog, thus
extending
it, rather thanmodifying
it and you use the abstract to interface with the concrete implementation returned from the Factory.