Skip to content

πŸš€ 3단계 - 사닀리(κ²Œμž„ μ‹€ν–‰) #2370

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

Open
wants to merge 9 commits into
base: nno0obb
Choose a base branch
from

Conversation

nno0obb
Copy link

@nno0obb nno0obb commented Apr 12, 2025

  • Bridge λ§ŒμœΌλ‘œλŠ” 사닀리 타기가 μ–΄λ €μ›Œ LeftBridge 와 RightBridge 둜 λΆ„λ¦¬ν•˜μ˜€μŠ΅λ‹ˆλ‹€
  • κΈ°μ‘΄ μ½”λ“œλ₯Ό μœ μ§€λ³΄μˆ˜ν•œλ‹€λŠ” λŠλ‚ŒμœΌλ‘œ LeftBridge λ₯Ό μ€‘μ‹¬μœΌλ‘œ λ‘œμ§μ„ κ΅¬ν˜„ν•˜μ˜€μŠ΅λ‹ˆλ‹€
  • 이것저것 클래슀λ₯Ό 많이 λ§Œλ“€κΈ΄ ν–ˆμ§€λ§Œ... GameTest 둜 μΆ©λΆ„ν•˜λ‹€κ³  μƒκ°ν–ˆμŠ΅λ‹ˆλ‹€
  • BoardResult λŠ” "Map" 으둜 κ΅¬ν˜„ν•˜μ˜€μŠ΅λ‹ˆλ‹€

각 객체가 2개 μ΄ν•˜μ˜ μΈμŠ€ν„΄μŠ€ λ³€μˆ˜λ§Œμ„ 가지도둝 κ΅¬ν˜„ν•΄ λ³Έλ‹€.

Point 뢀뢄은 2개 μ΄ν•˜λ‘œ ν•  수 μžˆλŠ” νžŒνŠΈκ°€ μžˆμ„κΉŒμš”...?

Copy link
Member

@testrace testrace left a comment

Choose a reason for hiding this comment

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

μ•ˆλ…•ν•˜μ„Έμš” ν™κ· λ‹˜ πŸ˜ƒ
3단계 κ΅¬ν˜„ μž˜ν•΄μ£Όμ…¨λ„€μš” πŸ‘
λͺ‡ κ°€μ§€ μ½”λ©˜νŠΈ λ‚¨κ²¨λ‘μ—ˆλŠ”λ° 확인해 μ£Όμ‹œκ³  λ‹€μ‹œ 리뷰 μš”μ²­ν•΄ μ£Όμ„Έμš”.

Copy link
Member

Choose a reason for hiding this comment

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

이 νŒŒμΌμ€ κ°œμΈμ„€μ •μ΄λ‹ˆ 컀밋에 ν¬ν•¨ν•˜μ§€ μ•Šμ•„λ„ 될 것 κ°™μ•„μš”.

Comment on lines +46 to +50
## # Step3 μš”κ΅¬μ‚¬ν•­

* 사닀리 μ‹€ν–‰ κ²°κ³Ό 좜λ ₯
- [x] κ°œμΈλ³„ 이름을 μž…λ ₯ν•˜λ©΄ κ°œμΈλ³„ κ²°κ³Όλ₯Ό 좜λ ₯
- [x] "all" 을 μž…λ ₯ν•˜λ©΄ 전체 μ°Έμ—¬μžμ˜ μ‹€ν–‰ κ²°κ³Όλ₯Ό 좜λ ₯ν•˜κ³  μ’…λ£Œ
Copy link
Member

Choose a reason for hiding this comment

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

쑰금 더 μž‘μ€ λ‹¨μœ„μ˜ κΈ°λŠ₯으둜 λΆ„λ¦¬ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?
TDDλ₯Ό κΈ°λ°˜μœΌλ‘œν•˜λ‹ˆ ν…ŒμŠ€νŠΈ μΌ€μ΄μŠ€μ™€ κΈ°λŠ₯ λͺ©λ‘κ³Ό λ§€μΉ­μ‹œμΌœλ„ 쒋을 것 κ°™μ•„μš”.

Comment on lines +46 to +62
public BoardResult play(Board board) {
Map<Name, Integer> resultMap = new HashMap<>();
IntStream.range(0, peopleNames.size())
.forEach(i -> {
Name name = peopleNames.get(i);
resultMap.put(name, i);
});
for (Line line : board.lines()) {
IntStream.range(0, peopleNames.size())
.forEach(i -> {
Name name = peopleNames.get(i);
resultMap.put(name, move(resultMap.get(name), line));
});
}

return new BoardResult(resultMap, resultNames);
}
Copy link
Member

Choose a reason for hiding this comment

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

play, move 같은 λ©”μ„œλ“œλŠ” 도메인 κΈ°λŠ₯으둜 λ΄μ•Όν•˜μ§€ μ•Šμ„κΉŒμš”?

BoardResult result = board.play();
Result result = board.play(μ°Έκ°€μž1);

μ»¨νŠΈλ‘€λŸ¬κ°€ μ•„λ‹Œ 도메인이 μˆ˜ν–‰ν•  수 μžˆλ„λ‘ 이동해 λ³΄μ‹œλ©΄ 쒋을 것 κ°™μ•„μš”.

Comment on lines +8 to +9
private final Map<Name, Integer> resultMap;
private final ResultList resultNames;
Copy link
Member

Choose a reason for hiding this comment

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

λ§€μΉ­ κ²°κ³Όλ₯Ό Map<Name, Result> νƒ€μž…μœΌλ‘œ κ°€μ§€λ©΄ μ–΄λ–¨κΉŒμš”?

Comment on lines +30 to +42
IntStream.range(1, points.size() - 1)
.filter(i -> points.get(i).leftBridge().isBuilt() && points.get(i + 1).leftBridge().isBuilt())
.findAny()
.ifPresent(i -> {
throw new IllegalArgumentException("Lineμ—μ„œ μ—°μ†λœ 사닀리가 있으면 μ•ˆλ©λ‹ˆλ‹€.");
});

IntStream.range(0, points.size() - 2)
.filter(i -> points.get(i).rightBridge().isBuilt() && points.get(i + 1).rightBridge().isBuilt())
.findAny()
.ifPresent(i -> {
throw new IllegalArgumentException("Lineμ—μ„œ μ—°μ†λœ 사닀리가 있으면 μ•ˆλ©λ‹ˆλ‹€.");
});
Copy link
Member

Choose a reason for hiding this comment

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

일뢀 μ±…μž„μ€ PointList둜 μ΄λ™ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?
Line#validate λ©”μ„œλ“œμ˜ 길이가 λ„ˆλ¬΄ 긴데 그만큼 μ±…μž„μ΄ λ§Žμ€κ²ƒμ΄ μ•„λ‹Œμ§€ κ³ λ €ν•΄ λ³΄μ‹œλ©΄ 쒋을 것 κ°™μ•„μš”

Comment on lines +10 to +13
public ResultList(List<String> results) {
validateResultList(results);
this.results = results.stream().map(Result::new).collect(Collectors.toList());
}
Copy link
Member

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 +34
public class GameTest {
@Test
@DisplayName("κ²Œμž„ κ²°κ³Ό ν…ŒμŠ€νŠΈ #1")
public void test() {
NameList nameList = new NameList(Arrays.asList("a", "b", "c"));
ResultList resultList = new ResultList(Arrays.asList("1", "2", "3"));
Height height = new Height(3);
Line line1 = new Line(new PointList(3));
Line line2 = new Line(new PointList(3));
Line line3 = new Line(new PointList(3));
line1.createLeftBridge(1); // |-| |
line2.createLeftBridge(2); // | |-|
line3.createLeftBridge(2); // | |-|

Board board = new Board(Arrays.asList(line1, line2, line3), nameList);

Game game = new Game(nameList, resultList, height);
BoardResult boardResult = game.play(board);

assertThat(boardResult.of(new Name("a"))).isEqualTo(new Result("2"));
assertThat(boardResult.of(new Name("b"))).isEqualTo(new Result("1"));
assertThat(boardResult.of(new Name("c"))).isEqualTo(new Result("3"));
}
Copy link
Member

Choose a reason for hiding this comment

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

사닀리 μ‹œκ°ν™” πŸ‘
컨트둀러둜 ν†΅ν•©ν…ŒμŠ€νŠΈλ₯Ό ν•΄μ£Όμ‹  것 같은데 μ•žμ„œ λ“œλ¦° μ½”λ©˜νŠΈ 처럼 μ‚¬λ‹€λ¦¬μ˜ κ²°κ³Όλ₯Ό λ§Œλ“œλŠ” μ±…μž„μ„ λ„λ©”μΈμœΌλ‘œ 보면 μ–΄λ–¨κΉŒμš”.
컨트둀러의 역할은 view, doamin κ°„μ˜ μ†Œν†΅κ³Ό 흐름을 μ œμ–΄ν•˜λŠ” κ²ƒμ΄λ‹ˆ play λΌλŠ” λ©”μ„œλ“œλŠ” λ„λ©”μΈμœΌλ‘œ μ΄λ™μ‹œμΌœμ•Όν•˜μ§€ μ•Šμ„κΉŒμš”?

Comment on lines +55 to +61
public void destroyLeftBridge() {
leftBridge = new LeftBridge(false);
}

public void destroyRightBridge() {
rightBridge = new RightBridge(false);
}
Copy link
Member

Choose a reason for hiding this comment

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

μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” μ½”λ“œλŠ” μ œκ±°ν•΄μ£Όμ„Έμš”

}

public Point(int x, LeftBridge leftBridge, RightBridge rightBridge) {
validatePoint(x);
Copy link
Member

Choose a reason for hiding this comment

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

validatePoint(x) 뿐만 μ•„λ‹ˆλΌ 연속여뢀λ₯Ό κ²€μ¦ν•˜λŠ” validatePoint λ©”μ„œλ“œλ„ ν˜ΈμΆœν•΄μ•Όν•˜μ§€ μ•Šμ„κΉŒμš”?

Point point = new Point(1);
point.createLeftBridge();

assertThatThrownBy(() -> point.createRightBridge()).isInstanceOf(IllegalArgumentException.class)
Copy link
Member

Choose a reason for hiding this comment

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

우츑 μ—°κ²°λΆ€λ₯Ό 미리 생성해 두고 쒌츑 μ—°κ²°λΆ€λ₯Ό 생성 μ‹œ λ°œμƒν•˜λŠ” μ˜ˆμ™Έλ„ 검증해야 ν•˜μ§€ μ•Šμ„κΉŒμš”?
쉽진 μ•ŠμœΌμ‹œκ² μ§€λ§Œ TDD 사이클을 ν™œμš©ν•΄ λˆ„λ½λ˜λŠ” λ‹¨μœ„ ν…ŒμŠ€νŠΈκ°€ 없도둝 κ΅¬ν˜„ν•΄ λ³΄μ‹œλ©΄ μ’‹κ² μŠ΅λ‹ˆλ‹€.

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