Skip to content

Conversation

@qwer920414-ctrl
Copy link

안녕하세요! 메리크리스마스입니다.
3단계 미션 진행해보았습니다.
아직 더 진행해야하는 부분이 있는거 같기도한데, 우선 Session에 집중해서 구현해보았습니다.

고민됬던 부분은 이렇습니다.

  • 인터페이스 EnrollmentPolicy를 어떻게 데이터화해서 DB에 넣는지
  • Session과 Enrollment Repository를 어떻게 연결할지

변경을 최소화하려고 했는데, 일부 추가된 부분이 있습니다.
특히 jdbc에 데이터를 넣기 위해서 get 메소드가 많이 추가되었는데요.. 뭔가 찝찝했지만, 필요한거 같아서 추가했습니다.
그리고 SessionRepository에 Enrollment도 넣으려다가 따로 구현하고, 서비스를 만들어서 각각의 Repository를 묶었습니다.
요 방향이 맞는건지...확신은 없지만 서비스로 구현해두니 어느정도 계층이 구별되는거 같아보여요.
( 이렇게 domain/repository/service를 구별해서 실무에서도 개발하면 더 재밌을거 같습니다. )

좀 어설픈거 같아서.. 확인 부탁드리고, 피드백 주시면 더 깊게 고민해보겠습니다!

- Jdbc 연결을 위한 get 메소드 추가
- CoverImage fileName 필드 추가
- EnrollmentPolicy 필드 저장을 위한 데이터 추가(type, price)
- Test 코드 구현
- 인터페이스 생성
- 구현 로직 생성
- 테스트코드 구현
- domain/repository/service로 구분
- SessionService 구현(repository 묶음)
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 매핑 작업 넘 잘 했네요. 👍
기존의 도메인 객체를 최대한 유지하면서 적용한 점이 인상적이네요.

굳이 image와 같은 부분에 대한 작업은 하지 않아도 될 수 있는데요.
이 부분이 4단계 미션에 영향을 미치는 부분이 있어서요.
session외에 다른 부분까지 db 매핑한 후에 미션 마무리하고 4단계 진행하면 좋겠습니다.

추가로 domain 패키지에 도메인 클래스가 증가하고 있네요.
domain 패키지를 분리하는 도전도 추가로 진행해 보면 좋겠습니다.

FREE,
PAID;

public static EnrollmentPolicy create(String name, Long price) {
Copy link
Contributor

Choose a reason for hiding this comment

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

EnrollmentPolicy 생성을 PolicyType이 담당하기 보다 별도의 EnrollmentPolicyFactory와 같은 객체를 추가하는 것은 어떨까?

this.enrollmentRepository = enrollmentRepository;
}

public void enroll(Long sessionId, Long userId, Payment payment) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

public Enrollment enroll(Long userId, Payment payment) {
sessionState.validateEnroll();
enrollmentPolicy.validateEnrollment(payment);
return enrollments.add(this.id, userId);
Copy link
Contributor

Choose a reason for hiding this comment

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

메서드 이름이 add이면 반환 타입을 void로 예상할 가능성도 있어보임
AI와의 협업을 통해 더 적합한 이름이 있는지 피드백을 받아 적용해 본다.

- PolicyType의 역할 분리
- Enrollment 반환을 고려해서 enroll()로 수정
- session/enrollment로 패키지 생성
- Course -> Sessions 연동 추가
- JdbcCourseRepository 로직 추가
- SessionRepository - findByCourseId 추가
@qwer920414-ctrl
Copy link
Author

안녕하세요!
피드백 주신 부분 적용해보았습니다.
CourseRepository에 Sessions를 추가할때는 CourseRepository에서 SessionRepository를 주입하였습니다.
Course와 Session의 관계상 그렇게 적용해보았는데,
이 부분도 각각의 Repository를 구현하고, Service에서 묶는게 더 좋은 구조일까요?

그리고 get메소드에 대해서 질문드리면,
JDBC로 연동해보니, 갑자기 없던 get 메소드들을 추가할 수 밖에 없었는데 JPA에는 get 메소드 없이 매핑할 수 있는 기능이 있는걸까요?
아직 Mybatis만 사용해보고, JPA를 사용해보지 않았는데 그저 쿼리만 안짜도 된다 이렇게만 알고 있다가 이번 과정을 통해보니 JPA가 도메인 객체 설계방식의 마지막 피날레인거 같네요!

피드백 주시면 고민해보고 적용해보겠습니다! 감사합니다.
( 일정이 계속 있어서 매일 매일 작업하지 못하고 있네요ㅠㅠ 그래도 마감의 그날까지 달려보겠습니다! )

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