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

[1단계 - 보드 초기화, 기물 이동] 윌슨(박형균) 미션 제출합니다. #40

Open
wants to merge 64 commits into
base: phk1128
Choose a base branch
from

Conversation

phk1128
Copy link

@phk1128 phk1128 commented Mar 20, 2025

체크 리스트

  • 미션의 필수 요구사항을 모두 구현했나요?
  • Gradle test를 실행했을 때, 모든 테스트가 정상적으로 통과했나요?
  • 애플리케이션이 정상적으로 실행되나요?
  • 프롤로그에 셀프 체크를 작성했나요?

객체지향 생활체조 요구사항을 얼마나 잘 충족했다고 생각하시나요?

1~5점 중에서 선택해주세요.

  • 1 (전혀 충족하지 못함)
  • 2
  • 3 (보통)
  • 4
  • 5 (완벽하게 충족)

선택한 점수의 이유를 적어주세요.

기물에 관련된 기능들이 계층으로 잘 나누어져 있다.

어떤 부분에 집중하여 리뷰해야 할까요?

✅ 하위 객체에서 상위 객체를 참조해도 되는가??

현재 각 기물(JanggiChessPiece)들이 본인의 이동 경로를 탐색하기 위해상위 객체인 ChessPiecePositions를 매개변수로 받고 사용하고 있어요. 이 경우에는 아래와 같은 장단점이 있어요

  1. 장점
  • 매개변수로 보드를 받고 있기 때문에 테스트 하기 수월하다
  • 특정 보드에 종속되어 있지 않기 때문에 재사용성이 높다
  1. 단점
  • 하위 객체가 상위 객체를 사용하고 있는 상황이므로 순환 참조가 발생할 수 있다
  • ChessPiecePositions 변경이 각 기물에 전파될 수 있다

결과적으로 이처럼 장점과 단점이 공존하는 트레이드 오프 상황이라 현재 구조가 객체지향적인지 판단이 명확하게 되지 않는 상황인데요. 이에 대해서 로키의 생각은 어떠신지 궁금해요

phk1128 and others added 30 commits March 18, 2025 14:45
minSsan and others added 29 commits March 20, 2025 11:47
Copy link

@Rok93 Rok93 left a comment

Choose a reason for hiding this comment

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

윌슨 안녕하세요.
장기 미션을 함께하게된 로키입니다. 잘 부탁드려요! 🙇‍♂️

1단계 구현 잘해주셨습니다. 🤗👍
몇몇 코멘트 남겨두었는데, 확인해서 반영 해주세요. 😉
다음 리뷰 요청 때는 프롤로그 작성도 같이해서 요청부탁드릴게요. 🙏


import static org.assertj.core.api.Assertions.assertThat;

public class PathTest {
Copy link

Choose a reason for hiding this comment

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

PathTest와 PawnTest의 패키지 경로가 잘못 지정된 것 같아요. 👀


protected abstract List<Path> getCoordinatePaths();

protected abstract List<ChessPosition> getCoordinateDestinations(List<Path> coordinates, ChessPiecePositions positions);
Copy link

Choose a reason for hiding this comment

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

현재 각 기물(JanggiChessPiece)들이 본인의 이동 경로를 탐색하기 위해상위 객체인 ChessPiecePositions를 매개변수로 받고 사용하고 있어요. 이 경우에는 아래와 같은 장단점이 있어요
...

상위 객체라는 표현에 조금 혼동이 오는데요. 👀 (상위 타입을 말씀하시는건가했어요. 🙄)
먼저 상위 객체라고 표현하신 이유를 말씀해주시면 좋을 것 같아요. 😃

현재 getDestinations를 실제로 호출하고있는 부분은 없다보니 조금 더 실질적인 구현단을 보면
좋을 것 같은데, 아쉽게도 아직은 호출하고있는 곳이 없어보이네요. 🥲

실제로 장기판을 초기화하고 각 기물들을 턴에따라 이동시킬 수 있도록 만들어보면 어떨까요?
기물을 이동시킬 수 있는 콘솔 애플리케이션을 만들어보면 좋을 것 같아요. 😉

현재 보드 초기화 << 를 한 보드판이 따로 없는 것 같은데요.
저는 개인적인 생각에서는 ChessPiecePositions이 실질적인 보드판의 역할을 하기에 딱 좋아보인다고 생각이들어요.
저는 체스가 특정 칸으로 이동할 수 있는지 없는지 여부는 보드판의 역할이라고 생각해요.

저는 JanggiChessPiece가 현재 위치에서 자신이 갈 수 있는 모든 경로를 제공해주면
보드판이 현재 기물의 상황을 고려하여 이동할 수 있는 선택지를 추려서 보여주고 선택한 위치로 ChessPiece를 이동하라고 메시지를 보내주면 된다고 생각해요.

단순히 JanggiChessPiece의 기준에서는 특정 칸으로 이동하라고했을 때, 적절히 자신의 역할을 수행하면 될 것 같다고 생각해요.

Comment on lines +21 to +23
protected abstract List<Path> getCoordinatePaths();

protected abstract List<ChessPosition> getCoordinateDestinations(List<Path> coordinates, ChessPiecePositions positions);
Copy link

Choose a reason for hiding this comment

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

이 둘은 JanggiChessPiece 클래스 내부에서만 사용되는 것 같은데, 접근제한자를 protected로 두신 이유가 있으신가요? 👀

Comment on lines +37 to +38
@Override
protected abstract List<ChessPosition> getCoordinateDestinations(List<Path> coordinates, ChessPiecePositions chessPiecePositions);
Copy link

Choose a reason for hiding this comment

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

이미 상위 추상 클래스나 인터페이스에서 추상 메서드를 정의하고있다면, 별도로 선언하지 않아도 될 것 같아요.
UnlimitedMoveChessPiece, LimitedChessPiece , JanggiChessPiece, ChessPiece 모두 확인해서 하위타입에 불필요한 추상메서드 정의가 있다면 제거해주세요. 🙏

Suggested change
@Override
protected abstract List<ChessPosition> getCoordinateDestinations(List<Path> coordinates, ChessPiecePositions chessPiecePositions);

final List<Path> paths = new ArrayList<>();
for (Direction direction : directions) {
final List<ChessPosition> chessPositions = new ArrayList<>();
for (int distance = 1; distance <= 9; distance++) {
Copy link

Choose a reason for hiding this comment

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

1, 9는 이 코드를 처음보는 사람의 입장에서 어떤 의미를 가지는지 알기가 어려울 것 같아요. 😢
적절히 상수로 추출하여 네이밍으로 의도를 드러내보면 어떨까요? 🤗


import static domain.Direction.*;

public class King extends LimitedChessPiece {
Copy link

Choose a reason for hiding this comment

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

궁이나 궁성은 아직 구현하지 않아도 되니, 아쉽지만 King과 Guard는 잠시 제거해주시면 좋을 것 같아요. 🙏

2.1단계 미션 진행하면서 다시 부활시켜보시죠. 😉

import static domain.Direction.RIGHT;

public class Cannon extends UnlimitedMoveChessPiece {
private static final List<Direction> directions = List.of(UP, DOWN, LEFT, RIGHT);
Copy link

Choose a reason for hiding this comment

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

상수는 상수 네이밍 규칙에 맞게 명명해주세요. 😉

import java.util.ArrayList;
import java.util.List;

public abstract class LimitedChessPiece extends JanggiChessPiece {
Copy link

Choose a reason for hiding this comment

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

LimitedChessPiece는 LimitedMoveChessPiece 를 의미하시는걸까요..?
혹시 깜빡하고 Move가 빠진거라면 조금 더 명확한 의미 전달을 위해서 추가해주시면 좋을 것 같아요. 😃

LimitedChessPiece 와 UnlimitedMoveChessPiece 는 어떤 차이가있나요?

언뜻 보기에는 움직임에 제한이 있냐 없냐의 차이인 것 같은데 의미를 바로 이해하기가 조금 어려운 것 같네요.
조금 더 추가적인 설명을해주시면 좋을 것 같아요.

제가 잘 이해하지 못해서 그런걸 수도 있는데, UnlimitedMoveChessPiece, LimitedChessPiece의 계층을 두신 이유가 궁금해요. 🤔

image

Comment on lines +31 to +36
### 보드

- [ ] 특정 위치에서 이동 가능한 위치 리스트를 반환한다
- [ ] 점수를 계산 한다
- [ ] 예외 처리
- [ ] 해당 위치에 기물이 없으면 예외
Copy link

Choose a reason for hiding this comment

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

보드판은 구현이 아직 안된걸까요? 👀

@@ -1,3 +1,51 @@
# java-janggi

장기 미션 저장소

## 미션을 수행하며 반드시 고민할 것
Copy link

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