Skip to content

아이템61. 박싱된 기본 타입보다는 기본 타입을 사용하라. #154

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

You must be logged in to vote

정리해주신 글 잘 읽었습니다~

저는 웹 백엔드 개발을 할 때 path 에 논리(true / false) 타입 또는 정수 타입이 필요하면 원시 타입과 래퍼 클래스 중 스펙을 고민하곤 합니다.

예를 들면, JpaRepository 내 추상 메서드 중 Boolean 반환 타입인 추상 메서드의 값을 바탕으로 후속 작업을 해야 할 때,
원시 타입이면 조건문을 간소화할 수 있지만, 래퍼 클래스는 Boolean.TRUE 또는 Boolean.FALSE 등을 활용해서 비교해야 하는 것처럼요.

아니면 path variable 에 포함된 정수 타입은 null 이 들어오지 않는다는 것이 정책상 명확하다면, 굳이 원시 타입을 안 쓸 이유가 있는가? 처럼요.
여러분들의 의견은 어떤지 궁금합니다.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

@Irisation23
Comment options

@JoisFe
Comment options

@chikeem90
Comment options

Answer selected by YuDeokRin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9장 일반적인 프로그래밍 원칙 이펙티브 자바 9장 (일반적인 프로그래밍 원칙)
5 participants