I am curious about it because I talked with a friend about the strategy pattern, and we diverge about when we have to use it.
Our scenario is that I have to build a view component with 3 variants. All variants have particular colors and ways to resolve the string content, and it is supposed never to change. We don't know when the designers will create new views to this feature.
To do that, I decided to implement a simple strategy pattern using interfaces to create configurations. For example, I have IViewContentStrategy
and IViewStyle
as obligatory for any variant, and then I have two more optional interfaces, IViewAccessibility
and IViewTouchable
. Our view has to receive it and set up itself using these parameters. For example, if my strategy extends IViewTouchable
, it will accept touch.
So I have two views that should accept Touch and Accessibility and one that doesn't need it.
My question is if I should start it using Enums
with some conditions instead of strategy pattern?