-
Notifications
You must be signed in to change notification settings - Fork 212
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
feat : Step3 수강신청(DB 적용) #201
Conversation
qkrxodud
commented
Jun 18, 2023
- step2를 삭제하고 진행 했어야 됬는데, 삭제하지 않고 작업을 하다 꼬였네요. 😢😢😢
- step4 부터는 커밋단위를 좀 더 나눠서 진행하도록 하겠습니다.
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.
도메인 객체와 DB 매핑하느라 노력한 흔적이 보이네요. 👍
DB 매핑 객체를 도메인 객체로 변환하는 부분도 보이네요.
도메인 객체와 DB 매핑 객체 관련해 피드백 남겨봤어요.
this.id = id; | ||
this.title = title; | ||
this.students = new Students(); | ||
this.imageFile = new ImgFile(imageFile); | ||
sessionDuration = new SessionDuration(startedAt, endedAt); |
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 void changeStudents(Students students) { | ||
this.students = students; | ||
} | ||
|
||
public void removeStudent(NsUser nsUser) { |
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.
메서드 이름을 putStudent, removeStudent과 정하면 자료구조에 데이터를 추가하고 제거하는 느낌이 든다.
이 보다는 도메인 의도가 드러나도록 enroll(수강신청), cancel(수강취소)와 같은 이름으로 구현하면 어떨까?
checkCourseDuration(startedAt, endedAt); | ||
this.startedAt = startedAt; | ||
this.endedAt = endedAt; | ||
} | ||
|
||
void checkCourseDuration(LocalDate startedAt, LocalDate endedAt) { | ||
void checkCourseDuration(LocalDateTime startedAt, LocalDateTime endedAt) { |
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.
void checkCourseDuration(LocalDateTime startedAt, LocalDateTime endedAt) { | |
private void checkCourseDuration(LocalDateTime startedAt, LocalDateTime endedAt) { |
private으로 구현해도 되지 않을까?
int update(Session session); | ||
|
||
int delete(Long id); | ||
Optional<List<Session>> findBySessionIds(List<Long> sessionIds); |
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.
Optional<List<Session>> findBySessionIds(List<Long> sessionIds); | |
List<Session> findBySessionIds(List<Long> sessionIds); |
값이 없는 경우 빈 List 콜렉션을 반환하면 되기 때문에 콜렉션의 경우 굳이 Optional로 구현할 필요가 있을까?
|
||
import java.time.LocalDateTime; | ||
|
||
public class SessionUserMapping { |
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.
👍
|
||
import java.time.LocalDateTime; | ||
|
||
public class SessionUserMapping { |
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.
클래스명에 굳이 Mapping이 필요할까?
SessionUser와 같이 구현해도 되지 않을까?
import java.time.LocalDateTime; | ||
|
||
public class SessionUserMapping { | ||
private Long id; |
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.
private Long id; | |
private final Long id; |
가능하면 인스턴스 변수의 경우 final로 구현하고, 값을 변경해야 하는 경우에만 final을 제거하면 어떨까?
private final Map<Long, NsUser> studentsMap = new HashMap<>(); | ||
private Map<Long, NsUser> studentsMap = new HashMap<>(); | ||
|
||
private List<NsUser> users = new ArrayList<>(); |
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.
private List<NsUser> users = new ArrayList<>(); | |
private List<SessionUserMapping> users = new ArrayList<>(); |
수강신청한 학생의 목록은 SessionUserMapping을 가지는 것은 어떨까?
|
||
return session; | ||
} | ||
|
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.
수강신청 기능도 있어야 하지 않을까?
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.
피드백 반영 잘 했네요. 💯
소소한 피드백 몇 개 남겼는데요.
다음 단계 진행할 때 함께 반영해 보세요
import java.util.stream.Collectors; | ||
|
||
public class SessionUsers { | ||
List<SessionUser> sessionUserMappingList; |
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.
List<SessionUser> sessionUserMappingList; | |
private final List<SessionUser> sessionUserMappingList; |
} | ||
|
||
public void putEntity(Session session) { | ||
if (Objects.isNull(session)) { | ||
public void putEntity(SessionUser sessionUser) { |
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.
👍
|
||
|
||
@Service | ||
public class UserService { |
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.
UserService가 아니라 SessionService여야 하지 않을까?