This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
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?