static public List<String> TwitterHandles(List<Author> authors, String company) {
var result = new ArrayList<String> ();
for (Author a : authors) {
if (a.company.equals(company)) {
var handle = a.twitterHandle;
if (handle != null)
result.add(handle);
}
}
return result;
}
냄새 13. 반복문 (Loops)
리팩토링 33. 반복문을 파이프라인으로 바꾸기 (Replace Loop with Pipeline)
Before
After1(강의 예제)
After2