Thoughtworks interview question

How to refactor common code into a base class.