I have a code similar to following:
This code honestly speaking looks a bit ugly to me, so I was thinking of the ways to refactor it. I do have few ideas of refactoring this, however before reinventing wheel, I wanna to know if there is already any design
pattern made to solve such situation. The problem seems common enough to me, so is there a common pattern to refactor it? Did anyone have an experience with such situations?