-
Notifications
You must be signed in to change notification settings - Fork 0
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
GTB-25 [feat] 도메인 생성 #19
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
src/main/java/site/gachontable/gachontablebe/GachonTableBeApplication.java
Show resolved
Hide resolved
고생하셨습니다! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
엔티티를 만드는 과정에서 @NoArgsConstructor에 PROTECTED LEVEL를 주어 관리하신 점이 인상적이였습니다!
접근 권한을 Private로 하면 프록시 객체 생성에 문제가 생기고, 접근 권한을 Public으로 하면 무분별한 객체 생성 및 setter를 통한 값 주입을 할 수 있기에 접근 권한을 Protected로 작성하면 좋습니다!
그런데 양방향 매핑을 해서 외래키를 관리할 지, 아니면 단방향 매핑을 한 후 @onDelete(action = OnDeleteAction.CASCADE)
어노테이션을 적용해서 관리할 지 고민을 해보아야 할 것 같습니다.
가독성 측면에서 관리할 수 있는 필드가 줄어들기에 개인적으로 onDelete 어노테이션을 선호하지만,
성능적인 측면에서도 비교해본 후 결정할 부분이라고 생각됩니다.
보시면 좋을 참고링크를 첨부합니다
NOW-SOPT-SERVER/hoonyworld#9 (comment)
src/main/java/site/gachontable/gachontablebe/GachonTableBeApplication.java
Show resolved
Hide resolved
@Getter | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AllArgsContsturctor로 매개변수 있는 생성자를 만들어주는 것보다, builder 패턴이나 정적 팩토리메서드 패턴으로 관리하는게 더 좋을 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 프로젝트에서 매개변수 있는 생성자 대신 빌더 + 정적 팩토리 메서드 패턴으로 관리해준 예시입니다!
참고하시면 좋을 것 같아요 ㅎㅎ
public static Blog create(final Member member, final BlogCreateRequest blogCreateRequest) {
return Blog.builder()
.member(member)
.title(blogCreateRequest.title())
.description(blogCreateRequest.description())
.build();
}
@Builder
public Blog(Member member, String title, String description) {
this.member = member;
this.title = title;
this.description = description;
}
private Integer headCount; | ||
|
||
@Column(nullable = true) | ||
private Status waitingStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status에 대한 @Enumerated(EnumType.STRING)이 빠진 것 같습니다.
1. 무슨 이유로 코드를 변경했나요?
2. 어떤 위험이나 장애를 발견했나요?
3. 관련 스크린샷을 첨부해주세요.
4. 완료 사항
5. 추가 사항