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

[자판기] 유재건 미션 제출합니다. #167

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

Conversation

JaegeonYu
Copy link

No description provided.

Copy link
Member

@Choi-JJunho Choi-JJunho left a comment

Choose a reason for hiding this comment

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

프로그래밍 요구사항에 맞춰서 다시 리팩토링해보시면 좋을것같아요!

public int getAmount(){
return this.amount;
}
public static Coin of(int amount){
Copy link
Member

Choose a reason for hiding this comment

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

코드 포맷팅 해주시면 좋을것같아요!

Copy link
Author

@JaegeonYu JaegeonYu Dec 8, 2022

Choose a reason for hiding this comment

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

넵 시간 재면서 하다보니 리팩터링할 부분이 많은 것 같아요. 코멘트 주신 부분들 생각하면서 수정해볼게요 ~~ 코드리뷰 감사합니당

}

private void changeValidation(int change) {
if (change % coins.stream()
Copy link
Member

Choose a reason for hiding this comment

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

if 구문에 stream이 같이 들어가니 읽기가 조금 어렵네요 ㅠㅠ
coins.stream()... 에 대한 결과값을 변수로 한번 분리하는게 좋아보여요

return initCoin;
}

private void coinMaker(int change) {
Copy link
Member

Choose a reason for hiding this comment

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

해당 네이밍은 뭔가 클래스명처럼 보이네요..
createCoin과 같이 메소드 이름은 동사 혹은 동사구가 적합합니다.
참고 내용

}


public String startChangePrint() {
Copy link
Member

Choose a reason for hiding this comment

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

toString 혹은 printChange같은 네이밍은 어떨까요

changeAmount += tempCoin.getAmount();
}
}
return;
Copy link
Member

Choose a reason for hiding this comment

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

return을 작성하신 이유가 있을까요?

return;
}

public String leftChangePrint(){
Copy link
Member

Choose a reason for hiding this comment

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

printLeftChange라는 네이밍은 어떨까요

StringBuilder print = new StringBuilder();
print.append(CHANGE_MESSAGE.getMessage());
for (Coin tempCoin : leftCoins.keySet()) {
if(leftCoins.get(tempCoin) >0){
Copy link
Member

Choose a reason for hiding this comment

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

if(leftCoins.get(tempCoin) >0)

위 구문이

if(!isExhusted(tempCoin))

이렇게 작성되면 보다 읽기가 수월하다고 생각하기 때문에 저는 보통 if 내부에 존재하는 조건을 문장으로풀어쓰기위해 method로 한번 더 분리하곤 합니다.

this.count = count;
}

private void productValidate(int count) {
Copy link
Member

Choose a reason for hiding this comment

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

네이밍으로 validateProduct는 어떨까요

this.products = products;
}

public void productExist(String productName) {
Copy link
Member

Choose a reason for hiding this comment

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

getProduct라는 네이밍은 어떨까요
내부에서 검증하는 것 까지 외부에서 굳이 알 필요가 없다고 생각되네요

public int consumeProduct(String productName) {
for (Product o : products) {
if (o.getName().equals(productName)) {
if (o.getCount() == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

3depth가 넘어갔네요ㅠㅠ method를 분리하는 방향을 생각해보시는게 어떨까요

Comment on lines +64 to +68
public void saveLeftCoin(int amount){
if(amount >= startChange){
leftCoins = haveCoin;
return;
}

Choose a reason for hiding this comment

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

leftCoin이라는 메소드 명의 의미를 명확하게 파악하기 어려울 거 같아요!

Copy link
Author

Choose a reason for hiding this comment

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

네이밍이 어렵네요.. 리뷰 감사합니다 !

Comment on lines +12 to +17
public Product(String name, int price, int count) {
productValidate(count);
this.name = name;
this.price = price;
this.count = count;
}

Choose a reason for hiding this comment

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

product 클래스가 가진 것들은 잘 나눠주신 거 같습니다!

Comment on lines +35 to +38
public int sell(){
count --;
return price;
}

Choose a reason for hiding this comment

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

오 sell을 통해서 수량을 줄이는게 명확한거 같아요!

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