Notes on 'Refactoring' -- 5.2 Replace Exception with Test
Before Refactoring
if(index >= list.size()){ return null; } return list.get(index);Benefits: Avoid too many exceptions since it is not so good to read and it should only be used for an exception flow.