refactor Compound, Decorator and Factory