Skip to content
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

Merged
merged 9 commits into from
Jun 22, 2023
Merged

Conversation

qkrxodud
Copy link

  • step2를 삭제하고 진행 했어야 됬는데, 삭제하지 않고 작업을 하다 꼬였네요. 😢😢😢
  • step4 부터는 커밋단위를 좀 더 나눠서 진행하도록 하겠습니다.

Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

도메인 객체와 DB 매핑하느라 노력한 흔적이 보이네요. 👍
DB 매핑 객체를 도메인 객체로 변환하는 부분도 보이네요.
도메인 객체와 DB 매핑 객체 관련해 피드백 남겨봤어요.

Comment on lines 21 to 25
this.id = id;
this.title = title;
this.students = new Students();
this.imageFile = new ImgFile(imageFile);
sessionDuration = new SessionDuration(startedAt, endedAt);
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Optional<List<Session>> findBySessionIds(List<Long> sessionIds);
List<Session> findBySessionIds(List<Long> sessionIds);

값이 없는 경우 빈 List 콜렉션을 반환하면 되기 때문에 콜렉션의 경우 굳이 Optional로 구현할 필요가 있을까?


import java.time.LocalDateTime;

public class SessionUserMapping {
Copy link
Contributor

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 {
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private List<NsUser> users = new ArrayList<>();
private List<SessionUserMapping> users = new ArrayList<>();

수강신청한 학생의 목록은 SessionUserMapping을 가지는 것은 어떨까?


return session;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수강신청 기능도 있어야 하지 않을까?

Copy link
Contributor

@javajigi javajigi left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<SessionUser> sessionUserMappingList;
private final List<SessionUser> sessionUserMappingList;

}

public void putEntity(Session session) {
if (Objects.isNull(session)) {
public void putEntity(SessionUser sessionUser) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍



@Service
public class UserService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserService가 아니라 SessionService여야 하지 않을까?

@javajigi javajigi merged commit c2b1fbd into next-step:qkrxodud Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants