public static List<List<Journey>> routesToShowFor(String itineraryId) {
var routes = routesFor(itineraryId);
routes = bearable(routes);
return routes;
}
private static List<List<Journey>> bearable
(List<List<Journey>> routes
) {
return routes.stream()
.filter(route -> sufferScoreFor(route) <= 10)
.collect(toUnmodifiableList());
}
이제
removeUnbearableRoutes
라는 긴 이름 대신 함수에 사용할 더 나은 짧은 이름을 쉽게
찾을 수 있다. 새 이름은
bearable
이 된다.
routesToShowFor
에 있는
routes
재대입은 보기 나쁘지만
5
장의 리팩터링과 같은 방향의 변
화이기 때문에 의도적이다.
5
장에서는 ‘어떤 데이터를 제자리에서 변경하는’ 코드를 ‘새로운 값
을 계산하고 참조가 이 새 값을 가리키게 하는’ 코드로 변경했다. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.