Skip to content

아이템 22. 인터페이스는 타입을 정의하는 용도로만 사용하라 #47

Answered by corock
coalong asked this question in 3. 과제
Discussion options

You must be logged in to vote

최근에 책에서 언급한 대로 상수용 인터페이스를 만들어서 사용한 적이 있어 얼굴이 홍당무가 됐습니다 😞
stackoverflow 등의 정보의 홍수 사이트 속에서 허우적대다 보면, 심심치 않게 final class 형태를 접할 수 있었습니다.
그 당시에는 final 키워드를 붙인 코드가 이질감이 느껴져 그냥 지나쳤는데, 적절한 이유를 상기하며 적재적소에 활용해야겠다는 성찰의 시간을 가졌네요 👍

P.S. 많은 사람들이(심지어 시니어 이상 급도 해당) 유틸리티 클래스를 만들 때 단/복수를 오용한다고 생각합니다.
이 자리를 통해 패키지명은 util (단수), 유틸리티 메서드를 제공하는 클래스 이름은 XXXs 처럼 복수형을 사용하자고 외쳐봅니다.

Replies: 4 comments 9 replies

Comment options

You must be logged in to vote
2 replies
@coalong
Comment options

coalong Jan 8, 2023
Maintainer Author

@JoisFe
Comment options

Comment options

You must be logged in to vote
1 reply
@coalong
Comment options

coalong Jan 10, 2023
Maintainer Author

Comment options

You must be logged in to vote
4 replies
@Irisation23
Comment options

@JoisFe
Comment options

@JoisFe
Comment options

@corock
Comment options

Answer selected by coalong
Comment options

You must be logged in to vote
2 replies
@coalong
Comment options

coalong Jan 10, 2023
Maintainer Author

@corock
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4장 클래스와 인터페이스 이펙티브 자바 4장 (클래스와 인터페이스)
5 participants