Spotting use cases for the Strategy pattern
The Strategy pattern is by far one of the most versatile patterns. Since it essentially conveys a framework to implement the principle of favoring composition over inheritance, we can extrapolate it to create whole systems and even code bases for our game project or even to create a custom engine. One close example that we have in this direction is Godot Engine’s Area2D and CollisionShape2D relationship. The Area2D region is composed of multiple CollisionShape2D classes but each CollisionShape2D can be composed of different Shape2D interfaces: CircleShape2D, RectangleShape2D, CapsuleShape2D, and so on.
In that example, the Shape property of CollisionShape2D supports multiple strategies; every single strategy inherits the Shape2D interface and implements its methods, such as collide(), draw(), and get_rect(), in different ways. So, CircleShape2D may implement it by calculating the circle’s radius, whereas RectangleShape2D...