Sobes.tech
Junior — Middle

Does modifying an interface in a subclass violate the principle of open-closed principle?

sobes.tech AI

Answer from AI

Modifying the interface in a subclass can violate the Open/Closed Principle if it changes the behavior expected from the base interface. The principle states that entities should be open for extension but closed for modification.

If a subclass changes the interface in a way that breaks the contract of the base class (for example, changing method signatures or their meaning), this is considered a violation of the principle. However, extending the interface with new methods or adding additional behavior without changing existing ones is permissible extension.

Does modifying an interface in a subclass violate the… - sobes.tech