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

[아이템 16] public 클래스에서는 public 필드가 아닌 접근자 메서드를 사용하라 #14

Open
punsoo opened this issue May 8, 2021 · 1 comment

Comments

@punsoo
Copy link
Member

punsoo commented May 8, 2021

p. 102를 보면

API를 수정하지 않고는 내부 표현을 바꿀 수 없고,

또 p. 103을 보면

클래스 내부 표현 방식을 언제든 바꿀 수 있는 유연성을 얻을 수 있다.

이렇게 내부 표현이란 단어가 자주 등장하는데요,

내부 표현을 달리 표현하는 방법엔 어떤 것이 있을까요?

public 필드를 없애거나, 필드의 타입을 바꾸거나 그런 것일까요???

@ghojeong
Copy link
Member

ghojeong commented May 9, 2021

내부 표현을 달리 표현하는 방법엔 어떤 것이 있을까요?

이건 포비가 수업시간에서 이미 다루었다고 생각합니다.
간단히 생각하면 포비의 엘레강트 수업시간에, Builder 클래스의 메서드가 명사형이라는 점을 생각해보세요.
표현 방식을 언제든 바꿀 수 있는 유연성이란, 결국 포피가 수업시간에서 getter 와 setter 를 금지한 이유와 동일합니다.
수업시간에, 포비가 getter 와 setter 를 왜 쓰지 말아야하는지에 대해서 말했던 것 기억나나요?

스크린샷 2021-05-09 오전 9 55 44

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