-
Notifications
You must be signed in to change notification settings - Fork 170
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
Step2 - 리팩터링(메뉴) #168
base: newvelop
Are you sure you want to change the base?
Step2 - 리팩터링(메뉴) #168
Conversation
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.
안녕하세요! 현오님, 개인사전으로 리뷰가 늦어졌네요. 🙏
Step2 잘 진행해주셨고, 코멘트를 남겼으니 확인해주세요.
궁금하신 점이 있다면 DM도 환영합니다!
즐거운 주말 되세요! 😄
public List<MenuGroup> findAll() { | ||
return menuGroupRepository.findAll(); | ||
public List<MenuGroupResponse> findAll() { | ||
return menuGroupRepository.findAll().stream().map(v -> menuGroupMapper.toMenuGroupResponse(v)) |
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.
규칙 4: 한 줄에 점을 하나만 찍는다.
객체 지향 생활 체조 원칙을 지켜보면 좋을 것 같아요~^^
import java.math.BigDecimal; | ||
import java.util.UUID; | ||
|
||
public class MenuProductResponse { |
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.
Setter가 필요한지 고민해보면 좋을 것 같아요. 우리는 이미 생성자를 통해서 데이터를 할당한것 같아요. ^^
다른 Response도 동일합니다.
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) | ||
@JoinColumn( | ||
name = "menu_id", | ||
nullable = false, | ||
columnDefinition = "binary(16)", | ||
foreignKey = @ForeignKey(name = "fk_menu_product_to_menu") | ||
) | ||
private List<MenuProduct> 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.
일급객체를 활용해보는걸 추천드려요~^^
menuProducts의 책임과 역할이 명확하게 구분될 수 있을것 같네요.
|
||
@Table(name = "menu") | ||
@Entity | ||
public class Menu { |
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.
Setter가 무분별하게 사용되지 않는지 생각해보면 좋을 것 같아요.
의미있는 Method는 코드를 읽기 좋게 만들어주죠!^^
if (isInvalidPrice(menuCreateRequest.getPrice(), menuProductList, productList)) { | ||
throw new IllegalArgumentException("올바르지 않은 가격"); | ||
} | ||
|
||
if (isInvalidName(menuCreateRequest.getName(), purgomalumClient)) { | ||
throw new IllegalArgumentException(); | ||
} |
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.
검증은 별도의 Method로 분리해보는건 어떨까요~?
중복코드를 줄일 수 있겠네요.^^
this.productId = productId; | ||
} | ||
|
||
public static List<MenuProduct> createMenuProductList(List<MenuProductRequest> menuProductRequestList, List<Product> productList) { |
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.
Entity가 MenuProductRequest
를 활용해야 되는 상황이네요.
Entity는 DTO를 모르는 상황을 만들어 준다면?? Entity는 결합도가 낮아질 것 같아요.^^
이런 의견을 나누는 글도 있었네요.^^
강의내용을 다시봐도 좋을 것 같아요~^^
메뉴에 대한 리팩토링을 진행했습니다