jeudi 12 septembre 2019

Remove duplication in Strategy pattern

I have a photo manipulation product that provides different effects.

There are may filters, however, for this example, there are:

Black & White Antique Sepia

I have implemented the strategy pattern to implement this with the following design…

strategy  The allows me to create a dream filter with the behaviours “Desaturate”, “Yellow Tint” and “Low Contrast”

This works well, however there is a problem in my design. Between the different behaviours, the is quite a lot of duplication. For example, Saturation behaviours and the Tint behaviours use the same RGBOffset function.

What design allows me to remove duplication while maintaining the above flexibility?

Aucun commentaire:

Enregistrer un commentaire