Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional Interfaces should be as specialized as possible #1

Open
wbluke opened this issue Nov 27, 2019 · 1 comment
Open

Functional Interfaces should be as specialized as possible #1

wbluke opened this issue Nov 27, 2019 · 1 comment

Comments

@wbluke
Copy link

wbluke commented Nov 27, 2019

image

함수형 인터페이스는 최대한 자세한 것이 좋습니다. 즉, 위 코드 보다 아래 코드가 더 낫습니다.

private boolean checkKindsOfCoordinate(final List<Point> pointList, final Function<Point, Integer> function) {
    Set<Integer> numberSet = pointList.stream()
            .map(function)
            .collect(Collectors.toSet());

    return numberSet.size() != 2;
}
private boolean checkKindsOfCoordinate(final List<Point> pointList, final ToIntFunction<Point> function) {
    Set<Integer> numberSet = pointList.stream()
            .mapToInt(function)
            .boxed()
            .collect(Collectors.toSet());

    return numberSet.size() != 2;
}
@dpudpu
Copy link
Member

dpudpu commented Nov 30, 2019

크.. 덕분에 좋은거 배웠습니다 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants