Merged
Conversation
- 불필요한 ResponseEntity 삭제 - 각 외부 로그인을 하나의 매핑으로 처리하도록 수정 - LoginType을 key-value 형식으로 사용
# Conflicts: # backend-submodule
Contributor
|
오 enum으로 변환할 때 걸리는 시간은 map을 이용해서 O(1)시간내로 단축한 점 인상적이네요😄😄 private static final Map<String, DevelopField> TYPE_MAP = Map.of(
"backend", BACKEND,
"frontend", FRONTEND,
"ai", AI,
"mobile", MOBILE,
"datascience", DATA_SCIENCE
);
private static final Map<String, DevelopField> SEARCH_KEYWORD_MAP = Map.of(
"백엔드", BACKEND,
"프론트엔드", FRONTEND,
"인공지능", AI,
"모바일", MOBILE,
"데이터", DATA_SCIENCE
);
public static DevelopField toEnum(String type) {
return TYPE_MAP.getOrDefault(type.toLowerCase(), NONE);
}
public static DevelopField toEnumBySearchKeyWord(String searchKeyword) {
return SEARCH_KEYWORD_MAP.getOrDefault(searchKeyword.toLowerCase(), NONE);
}그런데 혹시 private static final Map<String, DevelopField> TYPE_MAP = Map.of(
"backend", BACKEND,
"frontend", FRONTEND,
"ai", AI,
"mobile", MOBILE,
"datascience", DATA_SCIENCE,
"백엔드", BACKEND,
"프론트엔드", FRONTEND,
"인공지능", AI,
"모바일", MOBILE,
"데이터", DATA_SCIENCE
);하나의 map으로 통합하면 |
Contributor
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#️⃣ Issue
🔎 작업 내용
🤔상세 내용
엔티티
@NotNullrhk 과 @column(nullable = flase)
기존 User에서 @NotNull을 통해서만 null 검증을 진행했다. 이 경우, 데이터베이스에는 제약 조건이 설정되지 않기 때문에 두 가지를 모두 사용하여 프론트에서 정보를 받아와서 Serializable 시, 데이터베이스에 저장 시 모두에 검증할 수 있도록 수정했다.
@DaTa 도입 여부
💡@DaTa
💡Record
따라서, @DaTa와 Record 사용 시 불변 객체의 사용 여부를 통해 적절하게 둘 중 하나를 선택하면 될 것 같다.
@builder
Record의 경우, DTO로 사용되고 세부적인 필드 조절이 필요하지 않기 때문에 생성자 대신 record 위에 @builder를 추가하도록 수정
@NoArgsConstructor(
access = AccessLevel.PROTECTED)뜻 : 아무런 매개변수가 없는 생성자를 생성하되 다른 패키지에 소속된 클래스는 접근을 불허한다”
사용 이유
Enum
매핑을 위한 Map 도입
각 직군에 해당하는 문자열을 Enum 값으로 변경하는 코드가 아래와 같다.
switch 사용 시, 컴파일 최적화 여부에 따라 O(logN)이 소요될 수 있다. 또한, 확장 시 추가로 작성해야 하는 부분이 많아지 기 때문에 상대적으로 Fix된 코드이다. 단순한 데이터 매핑 시, Map을 통해 항상 O(1)로 고정된 성능을 가지도록 리펙터링한다.
EnumMap 사용에 관해
EnumMap은 Enum 값을 Key로 사용한다. 예를 들어 {DevelopField.BACKEND, “backend”} 처럼 사용된다. 그러나 해당 코드는 Enum 값을 Value로 사용하기 때문에 EnumMap 사용 시 부자연스럽다.
리펙터링 후
Controller
MemberController
OAuth2 API 통일
현재 Kakao, Naver, Google에 대한 메서드가 각각 존재하기 때문에 중복 로직이 발생한다.
따라서, PathVariable을 통해 공통 로직으로 처리하도록 수정했다.