Skip to content

[자동차 경주] 김연서 미션 제출합니다.#10

Open
daeGULLL wants to merge 10 commits intoJava-JavaScript-Language-Stuty:mainfrom
2025JavaGroupStudy:yeunsuh
Open

[자동차 경주] 김연서 미션 제출합니다.#10
daeGULLL wants to merge 10 commits intoJava-JavaScript-Language-Stuty:mainfrom
2025JavaGroupStudy:yeunsuh

Conversation

@daeGULLL
Copy link
Copy Markdown

@daeGULLL daeGULLL commented Feb 14, 2025

모든 리뷰 감사합니다~~

1. 신경써서 구현한 부분

마찬가지로 MVC패턴을 썼습니다. 이번에는 서비스와 모델을 분리하지 않으려했는데 좀 복잡하드라구요.
서비스는 어떤 모델을 넣어도 돌아가게 설계하는게 좋다구 배워놔서 최대한 로직과 모델이 강한 연관성을 갖지 못하게 해봤습니다.

2. 피드백이 필요한 부분

가독성, 그리고 디렉터리 설계, 까먹은 예외에 대해 말씀해주시면 감사할 것 같습니다!!

3. 내가 고려한 예외

이름 문자 5개 이하
횟수 입력 시 텍스트가 숫자일 것, 1 이상일것

created model & custom observer
ErrorMessage & SystemMessage enum
RacingGameView & removed CarView.java
RacingGameService,
회차반복경기기능->1회차경기기능
add - Validator.java
fix - Car.java, ErrorMessage.java, RacingGameController.java, RacingGameView.java
@daeGULLL daeGULLL changed the title [자동차 경주] 김연서 과제 제출합니다. [자동차 경주] 김연서 미션 제출합니다. Feb 18, 2025
Copy link
Copy Markdown

@piamin04 piamin04 left a comment

Choose a reason for hiding this comment

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

mvc 패턴이 어떤건지 알 수 있어서 좋았어요! 감사합니다:)

public String getMessage() {
return "Error: "+message;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

각 에러 메시지에 "Error: "를 미리 붙이지 않고, 왜 getMessage()에서 추가하도록 짠건지 궁금해요ㅕ!!
에러 메시지 문자열을 미리 완성하면 코드가 더 간결해질 것 같은데, 현재 방식이 더 나은 이유가 있을까요?!! 배우고 싶어요!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

에러는 메세지 출력 때 공통으로 나오는거니 enum에 넣기보단 view로 떠넘기는게 더 낫지 않을까 큰 생각없이 만들었습니다만 좀 더 효율적이려면 enum을 조작해서 에러부분을 스태틱으로 하던지 하면 될 것 같습니다! 크게 고민 안하고 한거라 거창한 이유는 없었습니다..ㅋㅋㅋ

Copy link
Copy Markdown
Contributor

@moongua404 moongua404 left a comment

Choose a reason for hiding this comment

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

옵저버 패턴이나 isPresent 등 제가 악숙하지 않은 부분을 많이 배워갑니다! 코드도 되게 깔끔해요ㅎㅎ
2주차 수고 많으셨습니다

public void addPosition(int dice) {
if(dice>3) this.position++;
observer.onCarMove(name, position);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0에서 9 사이에서 무작위 값을 구한 후 무작위 값이 4 이상일 경우라는 전진 조건을 자동차의 책임으로 본 이유가 있나요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

저걸 일종의 validation이라구 봐서 자동차 모델 안에 집어넣어두 되지 않을까 생각했습니다~~ 저 메세드는 내부에서 검사를 하지만 받은 파라미터가 뭘 뜻하는진 모르니까용 흠 먼가 사용이 부적절한가??

Optional<Integer> maxValue = cars.stream().map(Car::getPosition).max(Integer::compareTo);

String maxPositionCars = cars.stream()
.filter(n -> maxValue.isPresent() && n.getPosition()==maxValue.get())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isPresent()라는 메서드도 있는지 처음 알았어요
Optional, 즉 Null 처리를 위한 메서드가 있었네요

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

저도 점찍고 스크롤하다가 보여서 알게 되었읍니다..


int repetitionNumber = Integer.parseInt(input);
if(repetitionNumber<1)
racingGameView.printEndGuide();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

코드 포멧이 미션에서 제시된 거랑 다른 것 같아요! 전반적으로 코드 포멧을 맞추면 가독성이 높아질 것 같아요

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

오 그런가요 넴~~~


public interface CarObserver {
void onCarMove(String carName, int position);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

모델을 확장해서 뷰로 구현하는 구조라고 이해했는데(CarObserver가 model 패키지 내 인터페이스이고, 인터페이스를 구현한 것이 view 이기에), 모델이 뷰와 강한 의존관계를 갖게 되기 때문에 이러한 구조가 MVC 패턴에 적절한지에 대해서는 다시 생각해볼 부분이 있을 것 같아요! 옵저버를 컨트롤러와 연결시켜 컨트롤러가 다시 뷰에게 전달하는 방향이 더 좋지 않을까요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

저도 컨트롤러 매개가 더 낫지 않나 생각하고 있었는데 제 블로그 정리글을 보면 타 개발글들이 옵저버를 바로 뷰랑 연결하드라구요 일단 걔네들이 그러라구 하니 그러던 중...왜 이래야하는지는 추가 조사가 필요할 듯 싶습니다


public void makeCar(){
String[] carNames = racingGameView.readName().split(",");
for(String name : carNames) racingGameService.addCar(name);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for도 좋지만 forEach로 써도 가독성이 높을 것 같아요

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

오 그러게요 왜 그렇게 안했지 수정하겠습니다~~

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