SOLID-Open/Closed Principle

Details
Full Name

SOLID Open/Closed Principle (OCP)

Intent:

Software entities should be open for extension but closed for modification. Add new behavior by adding new code, not changing existing code.

When to Use:

  • Adding new features requires modifying existing working code

  • Frequent changes to a module break other parts of the system

  • You need a plugin or strategy-based extension mechanism

Prompt Example:

"Refactore diesen Code nach dem SOLID-Open/Closed Principle, sodass neue Varianten ohne Änderung des bestehenden Codes hinzugefügt werden können."