-
Notifications
You must be signed in to change notification settings - Fork 264
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
[레거시 코드 리팩터링 - 2단계] 우르(김현우) 미션 제출합니다. #571
Conversation
- Repository, Entity 추가
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.
안녕하세요 우르! 저도 미션 2단계를 다 하지 못한 상황이라…조금 늦게 리뷰를 해드리게 되었네요🥲
이번 미션의 핵심 요구사항이 단위 테스트하기 어려운 코드와 단위 테스트 가능한 코드를 분리하는 것인 만큼, 서비스 코드가 얼마나 잘 분리되어있는지에 초점을 맞춰서 리뷰하였습니다.
클래스별로 수행하는 책임이 명확하고 작은 단위로 잘쪼개져있어서, 코드를 읽는 내내 감탄했습니다👍
몇 가지 신경쓰이는 부분에 대해 코멘트 남겨두었으니, 확인 및 반영&답변 후 재요청 부탁드립니다!
+) 그리고 이전 1단계 미션에서 리뷰에 달아주신 코멘트들도 모두 확인했습니다…!
코멘트가 달리지 않은 것에 대해서 제 쪽에서 먼저 말씀을 드렸어야했는데, ‘나중에 말씀드려야겠다’고 생각해놓고 그대로 잊어버린 것 같아요…🥲
소통이 미흡했던 점 사과드립니다.
@@ -0,0 +1,15 @@ | |||
package kitchenpos.domain; |
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.
개인적으로, 저희 프로젝트에서 하던 것처럼 repository 패키지를 별도로 만들어주는 것도 좋을 것 같습니다!
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.
수정했습니다 !!!
@@ -0,0 +1,14 @@ | |||
package kitchenpos.dao.mapper; |
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.
Mapper를 따로 분리해서 구현해주셨군요...!
저의 경우 entity 클래스가 toDomain()
메서드를 구현하게 했는데, 우르가 구현하신 방식이 좀더 역할이 잘 쪼개진 것 같은 느낌이 드네요👀
} | ||
private Long id; | ||
private String name; | ||
private BigDecimal price; |
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.
price를 별도의 값객체로 분리해주면 관련 로직을 더 단순하게 만들 수 있을 것 같아요~!
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.
그 방법도 좋은 것 같네요
다만 현재는 domain이 하나의 domain 패키지에 존재할텐데, 만약 도메인이 패키지별로 분리가 된다면 price는 어디에 있는게 좋을까요??
그래서 위와 같은 생각으로 따로 값 객체를 만들지 않았습니다.
common이라는 패키지에는 넣기 너무 애매한 것 같아서요,,
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.
음 말씀을 들어보니 패키지 소속이 애매하긴 하네요,,,
저의 경우엔 패키지를 어그리거트 별로 크게 menu, order, table로 나눠주었는데요,
Product와 Menu가 유사한 라이프 사이클을 갖는다고 생각해서 동일한 패키지에 넣어주었는데, Price는 이 두 객체에서만 사용하니 menu 패키지에 포함시켜주었습니다.
import java.math.BigDecimal; | ||
import java.util.List; | ||
|
||
public class MenuProducts { |
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 changeStatus(final OrderStatus orderStatus) { | ||
if (this.orderStatus == OrderStatus.COMPLETION) { |
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.
이 로직을 OrderStatus의 메서드로 만들어도 좋을 것 같습니다!
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 OrderTable mapToOrderTable(final OrderTableEntity entity) { |
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.
⚠이 메서드는 OrderTableMapper에 정의되어 있는 메서드와 중복되는 것 같습니다...!
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.
감사합니다 !!
return orderTableDao.save(savedOrderTable); | ||
private void validateOrderTableNotCompletion(final Long orderTableId) { | ||
if (orderRepository.existsByOrderTableIdAndOrderStatusIn( | ||
orderTableId, OrderStatus.notCompletion()) |
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.
👍👍👍
return id; | ||
} | ||
private Long id; | ||
private Long tableGroupId; |
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.
앗 여기는 TableGroup 객체로 바꾸지 않으셨네요...!
혹시 특별한 이유가 있으신가요?👀
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.
OrderTable은 TableGroup를 가지는게 필수가 아니기도하고, OrderTable과 TableGroup은 경계가 있는 것 같아서 간접 참조를 했습니다.
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.
아하, 납득했습니다!👍👍
OrderLineItemFixture.createOrderLineItem(menu1), | ||
OrderLineItemFixture.createOrderLineItem(menu), | ||
OrderLineItemFixture.createOrderLineItem(menu3) | ||
); |
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.
data.sql을 지우고 fixture로 대체해주셨군요!
굿입니다👍👍👍
.usingRecursiveFieldByFieldElementComparator() | ||
.containsExactlyInAnyOrderElementsOf(List.of(tableGroup1, tableGroup)); | ||
} | ||
} |
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.
넵 !!!! 도메인에 꼭 필요한 테스트의 단위 테스트 작성했습니다!
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 String name; | ||
private BigDecimal price; |
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.
그 방법도 좋은 것 같네요
다만 현재는 domain이 하나의 domain 패키지에 존재할텐데, 만약 도메인이 패키지별로 분리가 된다면 price는 어디에 있는게 좋을까요??
그래서 위와 같은 생각으로 따로 값 객체를 만들지 않았습니다.
common이라는 패키지에는 넣기 너무 애매한 것 같아서요,,
} | ||
|
||
public void changeStatus(final OrderStatus orderStatus) { | ||
if (this.orderStatus == OrderStatus.COMPLETION) { |
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 OrderTable mapToOrderTable(final OrderTableEntity entity) { |
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.
감사합니다 !!
return id; | ||
} | ||
private Long id; | ||
private Long tableGroupId; |
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.
OrderTable은 TableGroup를 가지는게 필수가 아니기도하고, OrderTable과 TableGroup은 경계가 있는 것 같아서 간접 참조를 했습니다.
@@ -0,0 +1,15 @@ | |||
package kitchenpos.domain; |
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 setSeq(final Long seq) { | ||
public MenuProduct( | ||
final Long seq, | ||
final Product product, |
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.
수정했습니다 !
.usingRecursiveFieldByFieldElementComparator() | ||
.containsExactlyInAnyOrderElementsOf(List.of(tableGroup1, tableGroup)); | ||
} | ||
} |
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.
안녕하세요~!
리뷰도 잘 반영해주셨고 요구사항도 충족된 것 같아 이만 approve하도록 하겠습니다!
3단계에서 봬요!
return id; | ||
} | ||
private Long id; | ||
private Long tableGroupId; |
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 String name; | ||
private BigDecimal price; |
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.
음 말씀을 들어보니 패키지 소속이 애매하긴 하네요,,,
저의 경우엔 패키지를 어그리거트 별로 크게 menu, order, table로 나눠주었는데요,
Product와 Menu가 유사한 라이프 사이클을 갖는다고 생각해서 동일한 패키지에 넣어주었는데, Price는 이 두 객체에서만 사용하니 menu 패키지에 포함시켜주었습니다.
안녕하세요 아마란스 !!!
이번에 82개의 files changed가 있는데,, 미리 죄송합니다.
많은 이유가 기존에 클래스를 리팩터링 하는 과정에서 컴파일 에러가 너무 나서 테스트하기 힘들더라구요.
그래서 리팩터링 대상 클래스에 postfix로 2를 붙인 다음에, 리팩터링 완료하고 나서 숫자 2를 지웠습니다.
ex) ProductDao2 생성 -> 기존 ProudctDao 제거 -> ProductDao2를 ProductDao 로 수정
이번 미션에서는 JPA를 사용하지 않고 JdbcTemplate을 사용해서 구현해봤습니다.
중간에 매우 많은 파일 삭제하는 커밋이 있는데, 그게 위에서 작성한 부분이라 바로 넘기셔도 좋을 것 같아요
이번 리뷰 잘 부탁드립니다 !!