Capgemini Interview Question

How to refactor a piece of code.