A quick survey: Below are two methods that return school district ratings given a list of houses. Which method do you find more to the point?
Method A |
---|
public List<Rating> getDistrictRatings(List<House> houses, Price maxPrice) { Set<SchoolDistrict> districts = houses.stream() .filter(house -> house.price().isLessThan(maxPrice)) .map(house -> house.getSchoolDistrict()) .collect(Collectors.toSet()); return ratingService.rateDistricts(districts); } |
Method B |
public List<Rating> getDistrictRatings(Houses houses, Price maxPrice) { Set<SchoolDistrict>=> districts = houses.below(maxPrice) .getSchoolDistricts(); return ratingService.rateDistricts(districts); } |