-
Notifications
You must be signed in to change notification settings - Fork 748
π 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
base: nno0obb
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μλ
νμΈμ νκ· λ π
3λ¨κ³ ꡬν μν΄μ£Όμ
¨λ€μ π
λͺ κ°μ§ μ½λ©νΈ λ¨κ²¨λμλλ° νμΈν΄ μ£Όμκ³ λ€μ 리뷰 μμ²ν΄ μ£ΌμΈμ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄ νμΌμ κ°μΈμ€μ μ΄λ 컀λ°μ ν¬ν¨νμ§ μμλ λ κ² κ°μμ.
## # Step3 μꡬμ¬ν | ||
|
||
* μ¬λ€λ¦¬ μ€ν κ²°κ³Ό μΆλ ₯ | ||
- [x] κ°μΈλ³ μ΄λ¦μ μ λ ₯νλ©΄ κ°μΈλ³ κ²°κ³Όλ₯Ό μΆλ ₯ | ||
- [x] "all" μ μ λ ₯νλ©΄ μ 체 μ°Έμ¬μμ μ€ν κ²°κ³Όλ₯Ό μΆλ ₯νκ³ μ’ λ£ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ‘°κΈ λ μμ λ¨μμ κΈ°λ₯μΌλ‘ λΆλ¦¬νλ©΄ μ΄λ¨κΉμ?
TDDλ₯Ό κΈ°λ°μΌλ‘νλ ν
μ€νΈ μΌμ΄μ€μ κΈ°λ₯ λͺ©λ‘κ³Ό λ§€μΉμμΌλ μ’μ κ² κ°μμ.
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); | ||
} |
There was a problem hiding this comment.
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);
컨νΈλ‘€λ¬κ° μλ λλ©μΈμ΄ μνν μ μλλ‘ μ΄λν΄ λ³΄μλ©΄ μ’μ κ² κ°μμ.
private final Map<Name, Integer> resultMap; | ||
private final ResultList resultNames; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ§€μΉ κ²°κ³Όλ₯Ό Map<Name, Result>
νμ
μΌλ‘ κ°μ§λ©΄ μ΄λ¨κΉμ?
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μμ μ°μλ μ¬λ€λ¦¬κ° μμΌλ©΄ μλ©λλ€."); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μΌλΆ μ±
μμ PointListλ‘ μ΄λνλ©΄ μ΄λ¨κΉμ?
Line#validate λ©μλμ κΈΈμ΄κ° λ무 κΈ΄λ° κ·Έλ§νΌ μ±
μμ΄ λ§μκ²μ΄ μλμ§ κ³ λ €ν΄ λ³΄μλ©΄ μ’μ κ² κ°μμ
public ResultList(List<String> results) { | ||
validateResultList(results); | ||
this.results = results.stream().map(Result::new).collect(Collectors.toList()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μμ±μ λ΄λΆμ λ‘μ§μ λ§μ΄ νμ©νμλ κ² κ°μμ.
μμ± μμ μ λ‘μ§μ΄ νμνλ€λ©΄ μ μ ν©ν 리 λ©μλλ₯Ό νμ©νλ©΄ μ΄λ¨κΉμ?
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")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ¬λ€λ¦¬ μκ°ν π
컨νΈλ‘€λ¬λ‘ ν΅ν©ν
μ€νΈλ₯Ό ν΄μ£Όμ κ² κ°μλ° μμ λλ¦° μ½λ©νΈ μ²λΌ μ¬λ€λ¦¬μ κ²°κ³Όλ₯Ό λ§λλ μ±
μμ λλ©μΈμΌλ‘ 보면 μ΄λ¨κΉμ.
컨νΈλ‘€λ¬μ μν μ view, doamin κ°μ μν΅κ³Ό νλ¦μ μ μ΄νλ κ²μ΄λ play λΌλ λ©μλλ λλ©μΈμΌλ‘ μ΄λμμΌμΌνμ§ μμκΉμ?
public void destroyLeftBridge() { | ||
leftBridge = new LeftBridge(false); | ||
} | ||
|
||
public void destroyRightBridge() { | ||
rightBridge = new RightBridge(false); | ||
} |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ°μΈ‘ μ°κ²°λΆλ₯Ό 미리 μμ±ν΄ λκ³ μ’μΈ‘ μ°κ²°λΆλ₯Ό μμ± μ λ°μνλ μμΈλ κ²μ¦ν΄μΌ νμ§ μμκΉμ?
μ½μ§ μμΌμκ² μ§λ§ TDD μ¬μ΄ν΄μ νμ©ν΄ λλ½λλ λ¨μ ν
μ€νΈκ° μλλ‘ κ΅¬νν΄ λ³΄μλ©΄ μ’κ² μ΅λλ€.
Bridge
λ§μΌλ‘λ μ¬λ€λ¦¬ νκΈ°κ° μ΄λ €μLeftBridge
μRightBridge
λ‘ λΆλ¦¬νμμ΅λλ€LeftBridge
λ₯Ό μ€μ¬μΌλ‘ λ‘μ§μ ꡬννμμ΅λλ€GameTest
λ‘ μΆ©λΆνλ€κ³ μκ°νμ΅λλ€BoardResult
λ "Map" μΌλ‘ ꡬννμμ΅λλ€Point
λΆλΆμ 2κ° μ΄νλ‘ ν μ μλ ννΈκ° μμκΉμ...?