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

[2단계 - 사다리 게임 실행] 몰리(김지민) 미션 제출합니다. #412

Merged
merged 145 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 134 commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
09eff2d
docs(README.md): 기능 요구사항 정리
jminkkk Feb 20, 2024
c3611ac
test(PersonTest): 이름 검증 로직 테스트 작성
jminkkk Feb 20, 2024
fc9fbb3
feat(Person): 이름 검증 로직 작성
jminkkk Feb 20, 2024
6653ac1
test(LineTest): 라인 검증 로직 테스트 작성
jminkkk Feb 20, 2024
6674645
feat(Line): 라인 검증 로직 작성
jminkkk Feb 20, 2024
ad1df2e
test(PeopleTest): People 검증 테스트 작성
jminkkk Feb 20, 2024
eeb57ad
feat(People): People 검증 로직 작성
jminkkk Feb 20, 2024
8f7c474
test(LadderTest): Ladder 검증 테스트 작성
jminkkk Feb 20, 2024
233b959
feat(Ladder): Ladder 검증 로직 작성
jminkkk Feb 20, 2024
62b7858
test(LineTest): Line의 경로가 연달아 있지 않은지 검증하는 테스트 작성
jminkkk Feb 20, 2024
e4b4705
feat(Line): 연달아 있지 않은 Line의 경로를 생성하는 로직 작성
jminkkk Feb 20, 2024
38c0034
test(NameParserTest): 입력받은 이름을 파싱하는 테스트 작성
jminkkk Feb 20, 2024
8611540
feat(NameParser): 입력받은 이름을 파싱하는 로직 작성
jminkkk Feb 21, 2024
b686b45
feat(InputView): 높이를 입력받는 로직 작성
jminkkk Feb 21, 2024
e3374fe
test(NameFormatterTest): 형식에 맞춰 이름을 반환하는 테스트 작성
jminkkk Feb 21, 2024
6248314
feat(NameFormatter): 형식에 맞춰 이름을 반환하는 로직 작성
jminkkk Feb 21, 2024
4dd6267
test(LineFormatterTest): 형식에 맞춰 라인을 반환하는 기능 테스트 작성
jminkkk Feb 21, 2024
f3c1f14
feat(LineFormatter): 형식에 맞춰 라인을 반환하는 기능 작성
jminkkk Feb 21, 2024
77dcea7
test(NamesFormatterTest): 형식에 맞춰 이름들을 반환하는 테스트 작성
jminkkk Feb 21, 2024
75a2038
feat(NamesFormatter): 형식에 맞춰 이름들을 반환하는 로직 작성
jminkkk Feb 21, 2024
7332308
feat(OutputView): 형식에 맞춰 실행결과를 출력하는 로직 작성
jminkkk Feb 21, 2024
ef5a04a
feat(InputView): 입력 문구 출력 추가
jminkkk Feb 21, 2024
8c89ecc
feat(Ladder, LadderTest): 사다리의 정적 팩토리 메서드에 인원수 인자 추가
jminkkk Feb 21, 2024
007b784
refactor(LineTest): 연결 여부 변수명 교체
jminkkk Feb 21, 2024
64f266e
feat(Result, LineDto): 출력에 필요한 Dto 추가
jminkkk Feb 21, 2024
19da1be
feat(LadderGame, Application): 컨트롤러 작성 및 메인 메서드 추가
jminkkk Feb 21, 2024
fe1bc1f
refactor(LineTest): 경로 존재 여부 원시값 포장 테스트 작성
jminkkk Feb 22, 2024
a023ce8
refactor(Line, Path, LineInfo): 경로 존재 여부 원시값 포장
jminkkk Feb 22, 2024
8bf415d
refactor(LineTest): 연달아 있는 사다리 테스트 로직 수정
jminkkk Feb 22, 2024
c683dd0
style(PeopleTest, PersonTest, NamesFormatterTest): 필요없는 줄 제거
jminkkk Feb 22, 2024
958d538
refactor(LineTest): 라인의 생성자로 값 리스트를 받도록 변경
jminkkk Feb 22, 2024
a80f45a
refactor(Line): 라인의 생성자 변경, 검증로직 추가
jminkkk Feb 22, 2024
64a2af2
refactor(LadderTest): 사다리 정적 팩토리 메서드 인자 변경
jminkkk Feb 22, 2024
7460b56
refactor(src): 메서드 및 변수에 final 키워드 추가
jminkkk Feb 22, 2024
b9ca5e0
style(NameParserTest): 파일 끝에 개행 추가
jminkkk Feb 25, 2024
9f73c3e
refactor(formatter): formatter의 패키지 위치를 view 아래로 이동
jminkkk Feb 25, 2024
3897b47
refactor(Ladder): pathCount 변수 추출
jminkkk Feb 25, 2024
d815880
refactor(Line): 인원 수 검증이 아닌 경로의 사이즈로 검증
jminkkk Feb 25, 2024
1b21725
fix(Line): 경로 검증 시 depth를 1으로 줄이기 위해 메서드 추출
jminkkk Feb 25, 2024
164e846
refactor(parser): 패키지 위치를 view 아래로 이동
jminkkk Feb 25, 2024
a178d6a
test(LadderTest): 사다리 생성에 대한 테스트 추가
jminkkk Feb 25, 2024
9ceeb00
feat(FixedPathGenerator): 테스트를 위한 PathGenerator 구현체 생성
jminkkk Feb 25, 2024
6546037
feat(Line): equals 메서드 구현
jminkkk Feb 25, 2024
ddcab56
feat(Application): 예외 처리 추가
jminkkk Feb 25, 2024
76f9182
style(PersonTest): 파일 끝에 개행 추가
jminkkk Feb 25, 2024
e628677
test(LadderTest): 사다리의 개인별 결과를 확인하는 테스트 작성
jminkkk Feb 27, 2024
16d1d46
feat(Ladder): 사다리의 개인별 결과를 확인하는 로직 작성
jminkkk Feb 27, 2024
885cfbc
refactor(PathGenerator): 테스트에 용이하도록 List<Line>을 반환하도록 수정
jminkkk Feb 27, 2024
2b087bb
refactor(Ladder, Line): PathGenerator 로직 변경에 따른 생성 로직 수정
jminkkk Feb 27, 2024
2bcd82e
refactor(LinesGenerator): PathGenerator를 LinesGenerator으로 rename
jminkkk Feb 27, 2024
2fce25f
refactor(LinesGenerator): line 패키지 아래로 파일 위치 변경
jminkkk Feb 27, 2024
7afc04e
refactor(FixedLinesGenerator): test 패키지 아래로 위치 변경
jminkkk Feb 27, 2024
374e5e4
fix(Line, LadderTest): 잘못 계산된 사다리 타기 로직 변경
jminkkk Feb 27, 2024
1725073
test(LadderTest): 사다리의 전체 참여자의 결과를 확인하는 테스트 작성
jminkkk Feb 27, 2024
7474aa9
feat(Ladder): 사다리의 전체 참여자의 결과를 확인하는 로직 작성
jminkkk Feb 27, 2024
467bcdf
docs(REAMDE.md): 추가된 요구사항에 대한 기능 명세 작성
jminkkk Feb 27, 2024
3102ec3
test(ItemsTest): 결과 목록을 생성하는 테스트 작성
jminkkk Feb 27, 2024
005a39d
feat(Items): 결과 목록을 생성하는 로직 작성
jminkkk Feb 27, 2024
9aa99fd
test(ItemsTest): 최종 위치에 따라 해당하는 결과를 반환하는 테스트 작성
jminkkk Feb 27, 2024
3d42144
feat(Items): 최종 위치에 따라 해당하는 결과를 반환하는 로직 작성
jminkkk Feb 27, 2024
af02405
test(ItemFomatterTest): 실행 결과는 좌측 정렬하는 테스트 작성
jminkkk Feb 27, 2024
050ca08
feat(ItemFomatter): 실행 결과를 좌측 정렬하는 로직 작성
jminkkk Feb 27, 2024
d040eea
test(Item): 실행 결과는 이름을 가진다에 대한 테스트 작성
jminkkk Feb 28, 2024
dbfdee2
feat(Item): 실행 결과는 이름을 가진다에 대한 로직 작성
jminkkk Feb 28, 2024
791c3e1
refactor(Items,ItemsTest): Items는 Item 목록을 가지도록 변경
jminkkk Feb 28, 2024
325186c
test(ItemsTest): 참여 인원 수와 결과 목록의 수가 동일하지 않은 경우 테스트 작성
jminkkk Feb 28, 2024
5ff4dfe
feat(Items): 결과 목록 생성 시 참여 인원 수와 결과 목록의 수를 검증하는 로직 작성
jminkkk Feb 28, 2024
0beb4be
refactor(Items): 결과 목록 생성자 private 변경 및 기존 사용 코드 수정
jminkkk Feb 28, 2024
de2803c
feat(Result, Items): 기존 사다리 형태와 참여자 이름을 담고 있는 Result에 실행 결과 이름 추가
jminkkk Feb 28, 2024
8a88fcb
feat(InputView): 실행 결과의 목록을 입력받는 로직 추가
jminkkk Feb 28, 2024
d735f2e
refactor(LadderInfo): 사다리 형태와 참여자 이름을 저장하는 Result의 이름을 LadderInfo로 변경
jminkkk Feb 28, 2024
ee41901
test(NameParserTest): 실행 결과 목록이 쉼표로 구분하는 테스트 작성
jminkkk Feb 28, 2024
1c6a4ab
test(ResultFormatterTest): 전체 결과일 경우, :를 기준으로 이름과 결과를 포맷하는 테스트 작성
jminkkk Feb 28, 2024
73f9fc1
feat(ResultFormatter): 전체 결과일 경우, :를 기준으로 이름과 결과를 포맷하는 로직 작성
jminkkk Feb 28, 2024
c43a793
refactor(Ladder): 메서드명 수정 및 메서드 순서 조정
jminkkk Feb 28, 2024
224c4e0
feat(ItemFormatter, OutputView): 사다리 출력 시 실행 결과를 출력하는 기능 작성
jminkkk Feb 28, 2024
7401da5
refactor(ItemsFormatter): ItemFormatter에서 ItemsFormatter 추출
jminkkk Feb 28, 2024
3b0028c
feat(Result): 사다리 타기 완료 후, 결과를 저장하는 로직 작성
jminkkk Feb 29, 2024
27a240c
feat(InputView): 결과를 보고 싶은 사람 이름을 입력받는 로직 작성
jminkkk Feb 29, 2024
bb3d4e5
feat(LadderGame): all이 들어올 때까지 반복하여 사람 이름을 받는 로직 작성
jminkkk Feb 29, 2024
c33737a
feat(LadderGame, OutputView): 개인에 대한 결과인 경우, 결과만 출력를 출력하는 로직 작성
jminkkk Feb 29, 2024
53c3cf8
feat(OutputView, LadderGame): 전체 결과를 출력한 경우 게임을 종료하는 로직 작성
jminkkk Feb 29, 2024
6b4b225
refactor(ResultInfo): dto패키지 아래의 Result 레코드를 ResultInfo로 변경 및 Result …
jminkkk Feb 29, 2024
0e82e4c
test(ResultTest): 결과 목록에 해당하는 사람이 없는 경우 예외 테스트 작성
jminkkk Feb 29, 2024
f050e11
feat(Result): 결과 목록에 해당하는 사람이 없는 경우 예외 로직 작성
jminkkk Feb 29, 2024
a829054
refactor(Result): 이름이 해당하는 결과과 있는지 검증하는 메서드 추출
jminkkk Feb 29, 2024
4840e57
refactor(LadderGame): all 상수 추출
jminkkk Mar 1, 2024
e0fddcc
refactor(Name): name 문자열 포장을 위한 객체 생성
jminkkk Mar 1, 2024
cb14e71
test(PersonNameTest): 사람 이름에 대한 검증 테스트 코드 위치 변경
jminkkk Mar 1, 2024
d78b5ba
feat(PersonName): 사람 이름에 대한 검증 로직 위치 변경
jminkkk Mar 1, 2024
7b398e4
refactor(Item): name 문자열 포장
jminkkk Mar 1, 2024
9b43ed1
docs(README.md): 결과 이름에는 공백이 올 수 없음에 대한 제약 조건 추가
jminkkk Mar 1, 2024
b333695
test(ItemNameTest): 실행 결과의 이름이 공백일 경우 예외를 던지는 테스트 작성
jminkkk Mar 1, 2024
851659a
feat(ItemName): 실행 결과의 이름이 공백일 경우 예외를 던지는 로직 작성
jminkkk Mar 1, 2024
83617b5
refactor(Result): 접근제어자를 public에서 private로 변경
jminkkk Mar 1, 2024
cc598c2
refactor(HeightTest, LadderTest): Height 원시값 포장 및 관련 테스트 위치 변경
jminkkk Mar 1, 2024
4b78abe
feat(Height): 높이 검증 위치 변경
jminkkk Mar 1, 2024
e0d9490
refactor(PersonCount): 원시값 포장을 위한 객체 생성
jminkkk Mar 1, 2024
0db785c
test(PersonCountTest): 참여 인원에 대한 검증 테스트 추가
jminkkk Mar 1, 2024
f5bfa57
feat(PersonCount): 참여 인원에 대한 검증 로직 위치 변경 및 구현
jminkkk Mar 1, 2024
c576b24
refactor(PersonCount): PersonCount 객체로 사용 대체
jminkkk Mar 1, 2024
1827704
refactor(src/): people, ladder, items 패키지 생성 및 파일 위치 변경
jminkkk Mar 1, 2024
a4e6562
test(PeopleTest): 참여자들의 이름 중 중복되는 이름 검증 테스트 추가
jminkkk Mar 2, 2024
1641858
feat(People): 참여자들의 이름 중 중복되는 이름 검증 로직 추가 및 equals 구현
jminkkk Mar 2, 2024
2982817
refactor(RandomLinesGenerator): IntStream를 사용하여 로직 변경 및 Height에 불필요한 …
jminkkk Mar 2, 2024
ada3c62
refactor: 원시값을 포장한 객체의 필드명 value로 통일
jminkkk Mar 2, 2024
7409fd5
refactor(ItemCount, ItemsTest): ItemCount 객체 생성 및 기존 결과의 수 검증 테스트 위치 변경
jminkkk Mar 2, 2024
477b7c4
refactor(Items): findBy와 같은 역할을 하는 get 메서드 제거
jminkkk Mar 2, 2024
c144fd6
test(IndexTest): 원시값 포장을 위한 테스트 코드 추가
jminkkk Mar 2, 2024
ee50f71
feat(Index): index 원시값 포장 및 Index 구현
jminkkk Mar 2, 2024
00099fb
refactor(Ladder): while 문에서 IntStream을 사용하여 변경
jminkkk Mar 2, 2024
ad3a889
test(Index): 메서드 명을 직관적으로 수정
jminkkk Mar 2, 2024
bad0d60
fix(ItemFormatter): 결과 출력에서 포맷 형태 수정
jminkkk Mar 2, 2024
a66bfa2
refactor(RandomLinesGenerator): 가독성을 위한 메서드 추출
jminkkk Mar 2, 2024
5012257
Merge branch 'jminkkk' into step2
jminkkk Mar 2, 2024
9e16b5d
fix(src/): git 충돌 해결 중 발생한 중복 파일 제거
jminkkk Mar 3, 2024
48e1cfb
refactor(/dto): dto 클래스들의 이름을 info 에서 dto로 변경
jminkkk Mar 4, 2024
8210b69
refactor(Laddder): 사용하지 않는 필드인 height 제거
jminkkk Mar 4, 2024
fa71827
test(LadderTest): 사다리 생성 시 라인의 수와 높이가 일치하는지에 대한 검증 테스트 추가
jminkkk Mar 4, 2024
35c4447
feat(Ladder, Hegiht): 사다리 생성 시 라인의 수와 높이가 일치하는지에 대한 검증 로직 추가
jminkkk Mar 4, 2024
8cba210
refactor(line/): line 패키지를 ladder 패키지 아래로 수정
jminkkk Mar 4, 2024
009f318
refactor(line/): line 패키지를 ladder 패키지 아래로 수정
jminkkk Mar 4, 2024
b99ed5e
refactor(ResultTest): Person과 Item으로부터 결과를 생성하는 테스트 코드 작성
jminkkk Mar 4, 2024
8d34072
refactor(Result): 필드 및 생성자 수정
jminkkk Mar 4, 2024
3dcc6fc
test(ResultsTest): 결과 목록을 생성하는 테스트 작성
jminkkk Mar 4, 2024
fed6cf0
feat(Results): 결과 목록을 생성하는 생성자 추가
jminkkk Mar 4, 2024
9bbb749
test(ResultsTest): 결과 목록에서 사람에 해당하는 결과를 조회하는 테스트 작성
jminkkk Mar 4, 2024
94504fd
feat(Results): 결과 목록에서 사람에 해당하는 결과를 조회하는 로직 작성
jminkkk Mar 4, 2024
654de82
refactor(Results): 추가된 Results 객체가 기존 Result 대체하도록 변경
jminkkk Mar 4, 2024
0adfd07
refactor(Results): 테스트 하기 쉽도록 사람의 이름으로 결과를 찾을 수 있게 변경
jminkkk Mar 4, 2024
2a0a39e
refactor(ResultsDto, ResultDto): Result, Results 각각에 대한 dto 생성 및 구현
jminkkk Mar 4, 2024
abda7f8
refactor(LadderGame, ResultFormatter, OutputView): ResultDto, Results…
jminkkk Mar 4, 2024
4ac967f
refactor(LadderGame): All에 대한 상수를 OutputView로 이동
jminkkk Mar 4, 2024
142bcd0
Merge remote-tracking branch 'origin/step2' into step2
jminkkk Mar 4, 2024
7229cae
refactor(LadderGame, OutputView): 사다리 부분을 출력하는 로직 변경
jminkkk Mar 4, 2024
ed1e064
refactor(ResultDtosFormatter): ResultFormatter에서 ResultDtosFormatter로…
jminkkk Mar 4, 2024
699fee2
refactor(Ladder): 내부에서만 사용하는 climb 메서드의 접근 제한자를 private로 변경
jminkkk Mar 4, 2024
c6ec2a2
refactor(LadderDto): 사용되지 않는 Dto 제거
jminkkk Mar 4, 2024
e015ff6
refactor(ResultsDtoFormatter): ResultDtosFormatter의 인자를 ResultsDto로 변…
jminkkk Mar 4, 2024
03b629c
refactor: 불필요한 변수 할당 제거
jminkkk Mar 4, 2024
f65a0b2
refactor: 불필요한 import 문 제거
jminkkk Mar 4, 2024
f38831e
refactor(MatchedIndex): 매칭된 인덱스의 정보를 담는 불변객체 생성
jminkkk Mar 4, 2024
1c6337e
refactor(ItemName): 과한 원시값 포장 제거
jminkkk Mar 5, 2024
2c6d49b
refactor(PersonName): 과한 원시값 포장 제거
jminkkk Mar 5, 2024
c670c3e
refactor(Count): 과한 원시값 포장 제거
jminkkk Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
56 changes: 42 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
### 기능 요구사항 정리

Copy link

Choose a reason for hiding this comment

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

TDD cycle을 잘 지키기 위한 방법

아무래도 혼자하다보니 페어와 함께 했을 때보다 TDD cycle을 벗어나도 인지가 조금 늦게 되더라구요ㅠㅠ 그래서 1단계보다 cycle을 많이 어긴 것 같아 아쉽습니다..
졸업식 이슈로 시간이 촉박하게 느껴져 구현에 집중했던 것도 있구요..😭
또 처음 작성한 요구사항 명세서에 많은 부분들을 놓친 것 같아서 테스트할 부분들을 초기에 많이 놓쳤었다는 점도 아쉽습니다..
찰리는 TDD를 활용할 때 cycle을 잘 지킬 수 있는 방법 같은 게 있나요...?

TDD cycle을 잘 지키는 방법을 고민해봤는데 의식적인 연습 외에 생각나는 것이 없군요..!
자신도 모르게 기능 코드를 작성하는 때가 있는데

이 때 작성했던 코드를 지우고 다시 테스트 부터 작성하는 연습도 시도해볼 수 있겠군요 😄
이건 우테코처럼 교육 기간이나 개인적인 시간이 허락할 때 가능한 이야기이니 지금 시도해봐도 좋을것같아요~!

결론 : TDD 한다는 것을 계속 의식하면서 구현하는 연습을 해야합니다!

Copy link
Author

Choose a reason for hiding this comment

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

역시 의식적인 연습이 중요하군요! 다음 TDD 때는 더 의식적으로 TDD를 인지하면서 구현을 해봐야겠어요!
감사합니다 찰리:)

- [x] 사람의 이름을 갖는다.
- [x] 이름은 최소 1글자 최대 5글자다.
- [x] 이름은 최소 1글자 최대 5글자다.
- [x] 라인은 사다리의 가로 한줄을 의미한다.
- [x] 한 라인은 사람수보다 하나 적은 폭을 갖는다.
- [x] 사다리의 경로(path:가로라인)은 연달아 있을 수 없다. (나란히 있을 수 없다.)
- [x] 한 라인은 사람수보다 하나 적은 폭을 갖는다.
- [x] 사다리의 경로(path:가로라인)은 연달아 있을 수 없다. (나란히 있을 수 없다.)

- [x] 참여할 사람의 이름은 쉼표로 구분해 받는다.
- [x] 사람은 최소 2명 참가해야한다.
- [x] 실행 결과의 목록을 입력 받는다.
- [x] 실행 결과는 이름을 가진다.
- [x] 실행 결과의 이름은 공백일 수 없다.
- [x] 실행 결과 목록의 각 결과는 결과의 인덱스와 동일한 최종 위치의 사람에게 주어진다.
- [x] 사다리의 높이를 입력받는다.
- [x] 최소 높이는 1 이상이다.
- [x] 실행 결과를 출력한다.
- [x] 사다리를 출력한다.
- [x] 라인의 첫 부분은 ` ` 4칸으로 출력한다.
- [x] 5칸과 가장 오른쪽에 `|`를 높이만큼 출력한다.
- [x] 라인에 경로가 있는 경우 `-`를 5칸을 출력한다.
- [x] 라인에 경로가 없는 경우 ` `를 5칸을 출력한다.
- [x] 이름을 출력한다.
- [x] 이름이 4글자 이하인 경우, 오른쪽에 하나의 공백을 두고 우측 정렬한다.
- [x] 이름이 5글자인 경우, 공백없이 우측 정렬한다.
- [x] 사다리 타기 완료 후, 결과를 저장한다.
- [x] 결과를 보고 싶은 사람을 입력받는다.
- [x] 전체 결과를 보고 싶을 경우 all 을 입력한다.

- [x] 사다리 결과를 출력한다.
- [x] 사다리를 출력한다.
- [x] 라인의 첫 부분은 ` ` 4칸으로 출력한다.
- [x] 5칸과 가장 오른쪽에 `|`를 높이만큼 출력한다.
- [x] 라인에 경로가 있는 경우 `-`를 5칸을 출력한다.
- [x] 라인에 경로가 없는 경우 ` `를 5칸을 출력한다.
- [x] 이름을 출력한다.
- [x] 이름이 4글자 이하인 경우, 오른쪽에 하나의 공백을 두고 우측 정렬한다.
- [x] 이름이 5글자인 경우, 공백없이 우측 정렬한다.
- [x] 실행 결과를 출력한다.
- [x] 실행 결과는 좌측 정렬하여 출력한다.
- [x] 결과를 보고 싶은 사람에 대한 결과를 출력한다.
- [x] 개인에 대한 결과인 경우, 결과만 출력한다.
- [x] 전체 결과일 경우, :를 기준으로 이름과 결과를 출력한다.
- [x] 전체 결과를 출력한 경우 게임을 종료한다.

---

### 예외처리

- [x] 사람의 이름이 1글자 이하, 5글자 초과인 경우
- [x] 사다리의 높이가 1 이하인 경우
- [x] 참여할 사람의 이름이 쉼표로 구분되어 있지 않은 경우
- [ ] 참여한 인원 중 중복인 이름이 존재할 경우
- [x] 참여한 인원의 수가 1명 이하인 경우
~~- [ ] 실행 결과 목록이 쉼표로 구분되어 있지 않은 경우~~
- 쉼표 자체가 포함된 이름이 있을 수 있으므로 유효한 입력으로 취급한다.
- [x] 참여 인원 수와 결과 목록의 수가 동일하지 않은 경우
- [x] 결과를 보려는 사람이 사다리 참여자에 없는 경우
57 changes: 45 additions & 12 deletions src/main/java/controller/LadderGame.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package controller;

import dto.Result;
import dto.LadderDto;
import dto.ResultsDto;
import java.util.List;
import model.Ladder;
import model.People;
import model.path.RandomPathGenerator;
import model.Index;
import model.items.Item;
import model.ladder.Height;
import model.items.Items;
import model.ladder.Ladder;
import model.people.People;
import model.people.PersonCount;
import model.ladder.line.RandomLinesGenerator;
import model.result.Results;
import view.InputView;
import view.OutputView;

Expand All @@ -19,20 +26,46 @@ public LadderGame(final InputView inputView, final OutputView outputView) {

public void play() {
final People people = initPeople();
final Items items = initItems(people.getPersonCount());
final Ladder ladder = initLadder(people.getPersonCount());

final Result result = Result.from(people, ladder);
outputView.printResult(result);
}
final LadderDto ladderDto = LadderDto.from(people, ladder, items);
outputView.printLadderInfo(ladderDto);
Copy link

Choose a reason for hiding this comment

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

ladderDto 는 밑에서 재사용하는 부분이 없으니
다른 private 메서드들 처럼 추출하여 사용해보면 가독성이 올라가겠어요

// AS-IS
final LadderDto ladderDto = LadderDto.from(people, ladder, items);
outputView.printLadderInfo(ladderDto);

// TO-BE
printLadder(people, ladder, items);


final Results results = findResults(people, ladder, items);
searchResult(results);
Copy link

Choose a reason for hiding this comment

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

play() 를 전체적으로 읽을 때 어떤 일이 일어나는지 깔끔하게 표현됐네요 👍

}

private People initPeople() {
final List<String> names = inputView.inputNames();
return People.from(names);
final List<String> peopleNames = inputView.inputPeopleNames();
return People.from(peopleNames);
}

private Ladder initLadder(final PersonCount personCount) {
final Height height = new Height(inputView.inputHeight());
return Ladder.from(height, personCount, new RandomLinesGenerator());
}

private Items initItems(final PersonCount personCount) {
List<String> itemNames = inputView.inputItemsNames();
return Items.of(itemNames, personCount);
}

private Results findResults(final People people, final Ladder ladder, final Items items) {
List<Index> resultIndexes = ladder.climbAll();
Copy link

Choose a reason for hiding this comment

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

현재는 List의 Index에 의존하여 결과의 Index가 연결된 것으로 보여요.

  • resultIndexes.get(0) -> 0번째 참가자의 결과 Index
  • resultIndexes.get(1) -> 1번째 참가자의 결과 Index

이걸 객체로 표현해보면 어떨까요!

class Something {
    private final Index startIndex;
    private final Index resultIndex;
}

Copy link
Author

Choose a reason for hiding this comment

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

저도 이 부분이 조금 걸렸었는데 좋은 의견 감사합니다 찰리!

return Results.of(people, resultIndexes, items);
}

private Ladder initLadder(final int personCount) {
final int height = inputView.inputHeight();
return Ladder.from(height, personCount, new RandomPathGenerator());
private void searchResult(final Results results) {
String personName = inputView.inputPersonName();

while (!inputView.isEnd()) {
final Item item = results.findItemByPerson(personName);
outputView.printResultByPerson(item.getName());
personName = inputView.inputPersonName();
}

final ResultsDto resultsDto = ResultsDto.from(results);
outputView.printAllResult(resultsDto);
}
}
19 changes: 19 additions & 0 deletions src/main/java/dto/LadderDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dto;

import java.util.List;
import model.items.Items;
import model.ladder.Ladder;
import model.people.People;

public record LadderDto(List<String> peopleNames, List<LineDto> lines, List<String> itemNames) {
public static LadderDto from(final People people, final Ladder ladder, final Items items) {
final List<String> peopleNames = people.getNames();
final List<LineDto> lines = ladder.getLines()
.stream()
.map(LineDto::from)
.toList();
final List<String> itemNames = items.getNames();

return new LadderDto(peopleNames, lines, itemNames);
}
}
11 changes: 11 additions & 0 deletions src/main/java/dto/LineDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dto;
Copy link

Choose a reason for hiding this comment

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

dto 는 사실 view나 controller 에서 사용하고 있으니
적절한 곳에 하위 패키지도 놓아도 괜찮겠어요~

  • view.dto
  • controller.dto

어느곳이 더 어울리는지는 몰리의 고민거리로 남겨두겠습니다 😄


import java.util.List;
import model.ladder.line.Line;

public record LineDto(List<Boolean> lineInfo) {
public static LineDto from(final Line line) {
final List<Boolean> lineInfo = line.getExistFlags();
return new LineDto(lineInfo);
}
}
11 changes: 0 additions & 11 deletions src/main/java/dto/LineInfo.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/dto/Result.java

This file was deleted.

13 changes: 13 additions & 0 deletions src/main/java/dto/ResultDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dto;

import model.items.Item;
import model.people.Person;
import model.result.Result;

public record ResultDto(String personName, String itemName) {
public static ResultDto from(final Result result) {
Item item = result.getItem();
Person person = result.getPerson();
return new ResultDto(person.getName(), item.getName());
}
}
14 changes: 14 additions & 0 deletions src/main/java/dto/ResultsDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dto;

import java.util.List;
import model.result.Results;

public record ResultsDto(List<ResultDto> personAndItemName) {
public static ResultsDto from(final Results results) {
List<ResultDto> resultDtos = results.getResults()
.stream()
.map(ResultDto::from)
.toList();
return new ResultsDto(resultDtos);
}
}
25 changes: 25 additions & 0 deletions src/main/java/model/Count.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package model;

public abstract class Count {
Copy link

Choose a reason for hiding this comment

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

Count 를 추상 클래스로 만들어주신 이유가 궁금해요!

Count 를 구현한 PersonCount와 ItemCount가 Count 라는 개념으로 묶였을 때
코드상에서 어떤 관계가 표현됐을까요 🤔

Copy link
Author

Choose a reason for hiding this comment

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

카운트는 음수일 수 없다는 제약조건을 강제하고 각 Count에 맞는 검증을 추가할 수 있도록 하기 위해 추상 클래스로 구현했습니다!

Count 를 구현한 PersonCount와 ItemCount가 Count 라는 개념으로 묶였을 때 코드상에서 어떤 관계가 표현됐을까요 🤔

코드상에서는 PersonCount와 ItemCount가 Count의 한 종류이다! 라는 관계가 표현될 것 같아요

추가로 Countable이라는 인터페이스로 구현하려면, (검증 코드를 제외하고) Countable이라는 특성과 관련하여 사용될 행동이 있어야 한다고 생각해요.

그런데 제 코드에는 Countable의 특성에 맞는 필요한, 공통된 행동이 없다고 판단했어요. 그래서 검증 코드의 재사용을 위해 추상 클래스로 구현해도 괜찮을 것이라 생각했는데, 혹시 사용이 어색한지 찰리에게 묻고 싶어요!

Copy link

Choose a reason for hiding this comment

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

저는 추상화를 했다면 Count 타입으로 사용했을 때 어색함이 없어야한다고 생각해요!

그런 측면에서 public something(Count count) 라는 메서드가 있을 때 해당 인자로 PeopleCount, ItemCount 둘 다 넣어봐도 문제가 없을 정도로 ItemCount와 PeopleCount가 하나의 개념을 바라보고 있을까요? 🤔

ItemCount 와 PeopleCount이 동일한 추상화를 바라보는 객체인지 고민이 필요해보여요!

Copy link

Choose a reason for hiding this comment

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

더 이상 사용하지 않는 Count 클래스는 삭제해도 되겠군요 😉

private static final int MINIMUM_NUMBER = 0;

private final int value;

protected Count(final int rawCount) {
validateCount(rawCount);
validateNegativeCount(rawCount);
this.value = rawCount;
}

protected abstract void validateCount(final int rawCount);

private void validateNegativeCount(final int rawCount) {
if (rawCount < MINIMUM_NUMBER) {
throw new IllegalArgumentException("카운트는 음수일 수 없습니다.");
}
}

public int getCount() {
return value;
}
}
57 changes: 57 additions & 0 deletions src/main/java/model/Index.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package model;

import java.util.Objects;

public class Index {
Copy link

Choose a reason for hiding this comment

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

모든 원시값과 문자열을 포장한다의 범위

요구사항 중 "모든 원시 값과 문자열을 포장한다"에 대한 부분을 뒤늦게 인지하여, 1차 구현이 끝난 후 해당 요구사항을 만족하도록 리팩토링했습니다.
리팩토링을 하면서 들었던 의문이 이런 것까지 포장을 해야 하나? 라는 생각이었습니다.
예시로 PersonCount나 ItemCount과 같은 객체들을 도출하면서, Items나 People처럼 기존 일급 컬렉션 안에서 처리할 수도 있는 역할들을 추출한 것이 너무 과할 수도 있지 않을까 하는 생각이 들었구요...
이에 대한 찰리에 생각이 궁금합니다..!

정말 극한까지 원시값 포장을 해주셨군요 😮 👍

몰리가 생각하는 원시값(또는 문자열) 포장의 장점은 무엇인가요? 😄
의문을 가진것 처럼 너무 과했을 때 어떤 단점이 있을까요..!
(제가 생각했을 때는 코드에서 생성 또는 사용의 불편함이 먼저 떠오르는군요 😃 )

Copy link
Author

Choose a reason for hiding this comment

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

장점으로는 해당 값에 대한 검증을 포장한 객체 안에서 수행할 수 있다는 것 같아요..!
단점은 그만큼 관리해야 하는 객체가 늘어나고, 객체간의 관계를 파악하는데 추가적인 리소스가 발생할 수 있다..라고 생각합니다ㅎㅎ

Copy link

@Gomding Gomding Mar 4, 2024

Choose a reason for hiding this comment

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

처음 의문처럼 너무 작은것까지 원시값 포장을 진행한 것은 아닌지 의심이 됐어요 😃

name이라는 String을 포장한 객체가 Person이 아니었을까요! 🤔

Copy link
Author

@jminkkk jminkkk Mar 4, 2024

Choose a reason for hiding this comment

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

맞아요..!
제가 "모든"이라는 단어에 너무 심취해, Name, Count 같이 이미 포장된, 불필요한 객체를 한번 더 생성해버린 것 같다는 생각이 드네요..!🥲

private static final int MINIMUM_NUMBER = 0;

private final int value;

public Index(final int rawIndex) {
validateNegativeIndex(rawIndex);
this.value = rawIndex;
}

private void validateNegativeIndex(final int rawCount) {
if (rawCount < MINIMUM_NUMBER) {
throw new IllegalArgumentException("인덱스는 음수일 수 없습니다.");
}
}

public boolean isNotLastIndex(int last) {
return value < last;
}

public boolean isNotStartIndex() {
return value != 0;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Index index = (Index) o;
return value == index.value;
}

@Override
public int hashCode() {
return Objects.hash(value);
}

public int getIndex() {
return value;
}

public Index getNext() {
return new Index(value + 1);
}

public Index getPast() {
return new Index(value - 1);
}
}
34 changes: 0 additions & 34 deletions src/main/java/model/Ladder.java

This file was deleted.

35 changes: 35 additions & 0 deletions src/main/java/model/Name.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package model;

import java.util.Objects;

public abstract class Name {
private final String value;

protected Name(final String rawName) {
validateName(rawName);
this.value = rawName;
}

protected abstract void validateName(final String rawName);

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Name otherName = (Name) o;
return Objects.equals(value, otherName.value);
}

@Override
public int hashCode() {
return Objects.hash(value);
}

public String getName() {
return value;
}
}
Loading