Skip to content

Conversation

@Ussu1112
Copy link

토이프로젝트 제출합니다!

항상 코드리뷰 감사합니다.

이번 프로젝트를 진행하면서 아직도 객체 간의 관계에 대해 코딩하는 방법에 대해 조금 미숙한 듯 합니다.
코드를 더하면 더할수록 점점 주먹구구식으로 코딩을 하는 것 같아 어지럽습니다 🤣
보면 볼수록 코드를 어떻게 수정하면 더 괜찮은가에 대해 고민하게 되는 토이프로젝트 였습니다.
코드 리뷰와 피어 리뷰를 하면서 리팩토링을 계속 진행해보겠습니다!

@Ussu1112 Ussu1112 requested a review from ecsimsw May 10, 2023 14:37
@Ussu1112 Ussu1112 changed the title Tae hyoung song [1차] Java ToyProject upload by TaeHyoungSong May 10, 2023
Comment on lines 13 to 15
private final Groups allGroups = Groups.getInstance();
private final Customers allCustomers = Customers.getInstance();
private final MainMenu mainMenu = MainMenu.getInstance();
Copy link

Choose a reason for hiding this comment

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

의존성 주입부분은 저도 어떻게 해야될 지 잘 모르겠는데
같이 고민해볼까요?

Copy link
Author

Choose a reason for hiding this comment

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

싱글톤 객체를 주입받는 방식에 대해 찾아봤습니다...🤔
생성자 주입방식과 setter 주입방식를 자주 쓰지만
setter 주입방식은 코드의 유연성에 초점이 맞춰져 있는듯 하고,
생성자 주입방식은 객체의 불변성이나 코드의 가독성에 더 좋은듯합니다.

토이프로젝트에서는 생성자 주입방식이 더 낫지 않을까요?

private Groups allGroups;
private Customers allCustomers;
private MainMenu mainMenu;

private SmartStoreApp() {
    this.allCustomers = Customers.getInstance();
    this.allGroups = Groups.getInstance();
    this.mainMenu = MainMenu.getInstance();
}

Comment on lines 48 to 53
String cusName = null;
String cusId = null;
int cusTotalTime = 0;
int cusTotalPay = 0;

Customer customer = new Customer(cusName, cusId, cusTotalTime, cusTotalPay);
Copy link

@hyunsb hyunsb May 12, 2023

Choose a reason for hiding this comment

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

멘토님이 짚어주신 부분이었는데
Customer의 초기값을 설정하는 역할은 누가 가지는 게 맞을까요?

Copy link
Author

Choose a reason for hiding this comment

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

Customer의 초기값을 설정해주는 부분은 Customer의 생성자 쪽으로 넘겨서 처리해보았습니다.

변수들은 allCustomers에 set해주기 위해서 사용하는데 다시보니 굉장히 지저분해 보이네요.
set하는걸 별도로 빼는게 좋을까요?

@Ussu1112 Ussu1112 requested a review from hyunsb May 12, 2023 14:03

for (int i = saveIdx; i < allCustomers.size(); i++) {
Customer customer = allCustomers.get(i);
System.out.println(customer);
Copy link
Member

Choose a reason for hiding this comment

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

삭제될 때 출력해야 하는 요구 사항이 있었던가요? 😁

System.out.println("Which order (ASCENDING (A), DESCENDING (D))?");
String order = nextLine(Message.END_MSG);
if (order.equals("A") || order.equals("D")) return order;
else if (order.equals("end")) {
Copy link
Member

Choose a reason for hiding this comment

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

else if 가 필요할까요?

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