Skip to content

Instantly share code, notes, and snippets.

@pawelpluta
Created December 20, 2020 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawelpluta/c222012864f185fa43012d57c2714227 to your computer and use it in GitHub Desktop.
Save pawelpluta/c222012864f185fa43012d57c2714227 to your computer and use it in GitHub Desktop.
Article: Law of Demeter - company delegating cost calculation
class Company {
private List<Department> departments;
Map<DepartmentCode, BigDecimal> costPerDepartment() {
return departments.stream().collect(Collectors.toMap(Department::getCode, Department::cost));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment