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

학생 관리 프로그램 - 이태훈 #7

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Tentennball
Copy link

@Tentennball Tentennball commented Apr 8, 2024

내가 개발한 기능

  1. 학생 등록
  2. 학생 전체 조회(학번, 이름, 성적, 평균)
  3. 학생 검색->조회
  4. 학생 검색->정보 수정
  5. 학생 삭제

내가 개발할 때 유의 깊게 개발한 부분

  • 각 계층별로 기능을 정확히 나누려고 노력했다.
    • 컨트롤러에서는 서비스와 입출력만 신경쓰게 / 도메인을 사용하지 않고 DTO를 사용하게
    • 서비스에서 리포지토리 접근하기 및 도메인과 데이터 주고받기 등등..
  • 입출력메시지 같은 상수처리에 신경썼다.

내가 개발하면서 들었던 의문 사항

  • 책임분리/역할분리가 부족한 부분이 있는지 궁금하다.
  • 예외 처리를 할 때, 어떤 계층에서 검증이 이루어져야할지 헷갈렸다. 도메인을 생성시 검증은 할만한데 사용자에게 입력을 받을때 이에 대한 예외처리는 어떤 계층에서 처리하면 되는 지 헷갈렸다.
  • 정적 팩토리 메서드를 쓴다고 사용해보았는데 정확한 사용방법이 궁금하다.(수업시간에 설명해주시는 것도 좋을것 같습니다.)
  • 리포지토리에서 findAll을 통해 학생DTO의 배열을 컨트롤러로 반환해 주는데 이 방법이 컨트롤러의 책임분리에서 맞게 사용하였는지 궁금하다.
  • 코드 중 Stream으로 대체 가능한 코드부분들이 있는지 궁금하다.
  • 예외 처리가 전부 다 되었는지 궁금하다.

기능 면에서 부족했다고 생각되는 부분

  • 학번 대신 이름으로 검색하는 기능
  • 정렬기능을 추가한 조회기능

Copy link

@arty314 arty314 left a comment

Choose a reason for hiding this comment

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

계층을 분리하여 코드를 작성해주신 부분이 인상깊습니다. 이렇게 계층을 분리하면서 고민하고 노력해주신 부분이 보여 저도 배워야겠다고 생각했습니다.

다만, Controller와 Service 계층 사이에 인터페이스를 만들어 구현하면 의존성도 적어지고 추후 확장성과 유지보수 측면에서 도움이 될 것 같다는 생각이 듭니다.

Copy link
Member

@jinlee1703 jinlee1703 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.Scanner;

public class ManagementController {
ManagementService managementService;
Copy link
Member

Choose a reason for hiding this comment

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

이 부분은 private 접근 제어자로 설정해서 외부에서 접근을 하지 않도록 설정하는 것이 일반적인 것으로 아는데 default 접근제어자로 설정하신 이유가 따로 있으실까요?

Copy link
Author

Choose a reason for hiding this comment

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

앗 이건 제가 빠뜨리고 private를 쓰지 않은것 같네요..!ㅜㅜ

String cmd = InputView.readMenuBarCmd(scan);
Validate.isValidCmd(cmd);
switch (cmd) {
case "1"://학생 등록
Copy link
Member

Choose a reason for hiding this comment

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

지금처럼 주석을 사용하여 switch-case에서 각 case의 용도를 파악하는 것도 좋지만 이전에 사용하셨던 Constant 클래스를 사용하거나, Enum을 사용하는 것도 가독성 측면에서 좋은 방식이라고 생각합니다! 어떻게 생각하시나요??

Copy link
Author

Choose a reason for hiding this comment

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

상수처리하는 것을 깜빡한것 같아요..! 근데 Enum을 쓰는 방법은 생각치 못하고 있었는데 괜찮은 방법일 것 같아요!!

}

public void setAverage() {
this.average = (double)(koreanGrade + englishGrade + mathGrade) / GradeConstant.SUBJECT_CONUT;
Copy link
Member

Choose a reason for hiding this comment

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

현재는 setAverage 메서드가 빈번하게 호출되네요! 보다 호출을 줄이기 위한 방법을 고민해보셔도 좋을 것 같습니다!!
ex) average 멤버가 참조되기 직전에만 setAverage를 호출한다던가..

Copy link
Author

Choose a reason for hiding this comment

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

아 average가 참조되기 전에 사용하면 되겠군요!! 좋은 피드백 감사합니다!

studentRepository.save(student);
}

public StudentDTO findStudent(Scanner scan){
Copy link
Member

Choose a reason for hiding this comment

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

각 비즈니스 로직을 실행하기 위해 매번 Scanner 객체를 인자로 주고 있는데 이렇게 처리하신 의도가 궁금합니다!

Copy link
Author

Choose a reason for hiding this comment

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

Scanner라는 입력을 받는 객체를 어디에서 선언해야할지 고민하다가 View와 domain을 연결해주는 Controller부분에서 선언하는것이 맞다고 생각해서 그렇게 하였고, 이 생각으로 인해 다른 계층에서 따로 Scanner를 선언하지 않고 controller에서 인자로 주게 코딩한것 같습니다. 안그래도 이것때문에 고민을 많이 했는데 Scanner는 계층에 상관없이 선언해도 괜찮을까요??


public class StudentsRepository {

public static final Map<Integer, Student> students = new ConcurrentHashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

ConcurrentHashMap을 여기서 보게 되네요! 태훈님의 지식의 깊이를 알 수 있는 부분이네요 :)

Copy link
Author

Choose a reason for hiding this comment

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

감사합니다 ㅎㅎ:)

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.

3 participants