GoF-Strategy Pattern

Details
Full Name

GoF Strategy Pattern (Behavioral)

Intent:

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

When to Use:

  • Multiple related classes differ only in behavior

  • You need different variants of an algorithm

  • An algorithm uses data that clients shouldn’t know about

Prompt Example:

"Refactore diese Klasse nach dem GoF-Strategy Pattern, um die verschiedenen Berechnungsarten austauschbar zu machen."