Skip to content

πŸš€ 2단계 - 사닀리(생성) - #1963

Open
jeounpar wants to merge 6 commits into
next-step:jeounparfrom
jeounpar:step2
Open

πŸš€ 2단계 - 사닀리(생성)#1963
jeounpar wants to merge 6 commits into
next-step:jeounparfrom
jeounpar:step2

Conversation

@jeounpar

Copy link
Copy Markdown

μ•ˆλ…•ν•˜μ„Έμš”! 사닀리 λ―Έμ…˜ 2단계 리뷰 μš”μ²­λ“œλ¦½λ‹ˆλ‹€!

@testracetestrace left a comment

Copy link
Copy Markdown
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 +17
public Ladder(LadderHeight heightOfLadder, PersonCount countOfPerson, Random random) {
this.lines = new ArrayList<>();
IntStream.range(0, heightOfLadder.getHeightOfLadder())
.mapToObj(line -> new Line(countOfPerson.getCountOfPerson(), random))
.forEach(this.lines::add);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

μƒμ„±μžμ— 둜직이 ν¬ν•¨λ˜μ—ˆλ„€μš”
링크λ₯Ό μ°Έκ³ ν•΄ λ³΄μ‹œλ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€

IntStream 은 for문으둜 λŒ€μ²΄ν•  수 μžˆμ„ 것 κ°™μ€λ°μš”
IntStream 으둜 Line 객체듀을 μƒμ„±ν•˜μ‹  μ΄μœ κ°€ κΆκΈˆν•©λ‹ˆλ‹€

Random을 인자둜 λ°›μœΌλ©΄ 멱등성이 μ§€μΌœμ§€μ§€ μ•ŠλŠ” 것 κ°™μ•„μš”
λžœλ€μ„ μ‚¬μš©ν•˜λ”λΌλ„ μΈν„°νŽ˜μ΄μŠ€λ₯Ό λ§Œλ“€μ–΄μ„œ LadderλŠ” μΈν„°νŽ˜μ΄μŠ€μ— μ˜μ‘΄ν•˜λ„λ‘ λ³€κ²½ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?


private static final int MIN_HEIGHT = 1;

private final Integer heightOfLadder;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wrapper νƒ€μž…μ€ NPEκ°€ λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€
κΌ­ μ¨μ•Όν•˜λŠ” μ΄μœ κ°€ μ•„λ‹ˆλΌλ©΄ μ›μ‹œ νƒ€μž…μ„ μ‚¬μš©ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?

import java.util.List;
import java.util.Random;

public class LadderService {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” 주석, μ½”λ“œ(import 포함)은 μ œκ±°ν•΄ μ£Όμ„Έμš”

Comment on lines +12 to +18
public Line(int countOfPerson, Random random) {
this.points = new ArrayList<>();
this.points.add(random.nextBoolean());
IntStream.range(0, countOfPerson - 2)
.forEach(index -> initPoint(index, random.nextBoolean()));
validateLine(countOfPerson);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

여기도 μƒμ„±μž 내뢀에 둜직이 μžˆλ„€μš”
인자 countOfPerson 은 PersonCount νƒ€μž…μ„ ν™œμš©ν•˜λ©΄ μ–΄λ–¨κΉŒμš”?

κ°€λ‘œλΌμΈμ€ κ²ΉμΉ  수 μ—†λ‹€λŠ” μš”κ΅¬μ‚¬ν•­μ€ Line의 μ±…μž„μΌ 것 κ°™μ€λ°μš”
μƒμ„±μžμ— 둜직이 μžˆμ–΄μ„œ μš”κ΅¬μ‚¬ν•­μ„ 검증할 수 없을 것 κ°™μ•„μš”
μš”κ΅¬μ‚¬ν•­μ„ 검증할 수 μžˆλŠ” ꡬ쑰λ₯Ό κ³ λ―Όν•΄ λ³΄μ‹œλ©΄ 쒋을 것 κ°™μ•„μš”

Comment on lines +29 to +36
if (this.points.get(index) && nextBoolean || this.points.get(index) && !nextBoolean
|| !this.points.get(index) && !nextBoolean) {
this.points.add(false);
return;
}
if (!this.points.get(index) && nextBoolean) {
this.points.add(true);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

getterκ°€ λ„ˆλ¬΄ 많이 μ‚¬μš©λ˜κ³  μžˆλŠ” 것 κ°™μ•„μš”
λ©”μ‹œμ§€λ₯Ό λ³΄λ‚΄μ„œ ν•΄κ²°ν•  수 μ—†λŠ”μ§€, λ©”μ‹œμ§€λ₯Ό 보낼 객체λ₯Ό λ„μΆœν•  수 μ—†λŠ”μ§€ κ³ λ―Όν•΄ λ³΄μ‹œλ©΄ 쒋을 것 κ°™μ•„μš”

Comment on lines +24 to +29
@Override
public String toString() {
return IntStream.range(0, MAX_LENGTH - name.length())
.mapToObj(i -> SPACE)
.collect(Collectors.joining("", name, ""));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

좜λ ₯을 μœ„ν•΄μ„œ 곡백을 μΆ”κ°€ν•˜λŠ” λ‘œμ§μ„ 좜λ ₯의 μ±…μž„ μ•„λ‹κΉŒμš”?
μ°Έκ°€μžκ°€ λ§Žμ€ 경우 μ‚¬λ‹€λ¦¬μ˜ μ‹œμž‘ μœ„μΉ˜μ— 이름이 좜λ ₯되고 μžˆμ§€ μ•Šμ•„μš”
image

Comment on lines +11 to +23
@Test
@DisplayName("μ‚¬λ‹€λ¦¬μ˜ λ†’μ˜λŠ” 1 이상이닀")
void ladder_height() {
Assertions.assertThatThrownBy(() -> {
new LadderHeight(0);
}).isInstanceOf(IllegalArgumentException.class)
.hasMessage("λ†’μ΄λŠ” 1 이상 이어야 ν•©λ‹ˆλ‹€.");

Assertions.assertThatThrownBy(() -> {
new LadderHeight(-1);
}).isInstanceOf(IllegalArgumentException.class)
.hasMessage("λ†’μ΄λŠ” 1 이상 이어야 ν•©λ‹ˆλ‹€.");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

경계값인 0으둜 κ²€μ¦ν–ˆλŠ”λ° μΆ”κ°€λ‘œ -1도 κ²€μ¦ν•˜μ‹  μ΄μœ κ°€ μžˆμœΌμ‹ κ°€μš”?

Comment on lines +16 to +19
@Test
void ladder() {
Ladder ladder = new Ladder(new LadderHeight(5), new PersonCount(4), new AlwaysReturnTrue());
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

λ‹¨μœ„ ν…ŒμŠ€νŠΈ μž‘μ„±μ΄ λˆ„λ½λ˜μ—ˆλ„€μš”

Comment on lines +19 to +27
@Test
@DisplayName("μ‚¬λ‹€λ¦¬μ˜ 라인 ν•˜λ‚˜λ₯Ό μƒμ„±ν•œλ‹€")
void line() {
int countOfPerson = 5;
Line line = new Line(countOfPerson, new AlwaysReturnTrue());

assertThat(line.getPoints()).hasSize(countOfPerson - 1)
.containsExactly(true, false, true, false);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

DisplayNameκ³Ό ν…ŒμŠ€νŠΈ λ‚΄μš©μ΄ 일치 ν•˜μ§€ μ•Šλ„€μš”
ν…ŒμŠ€νŠΈμ˜ μ˜λ„μ™€ ν…ŒμŠ€νŠΈ λ‚΄μš©μ„ 일치 μ‹œμΌœμ£Όμ‹œλ©΄ 쒋을 것 κ°™μ•„μš”

μΆ”κ°€λ‘œ κ°€λ‘œ 라인은 κ²ΉμΉ  수 μ—†λ‹€λŠ” μš”κ΅¬μ‚¬ν•­μ΄ μžˆλŠ”λ° 이 검증은 μ–΄λ–»κ²Œ ν•  수 μžˆμ„κΉŒμš”?

Comment on lines +9 to +18
class OutputViewTest {

@Test
void print_ladder() {
Ladder ladder = new Ladder(new LadderHeight(10), new PersonCount(5),
new RandomTrueOrFalse());
OutputView outputView = new OutputView();
// outputView.printLadder(ladder);

}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ν…ŒμŠ€νŠΈκ°€ ν•„μš”ν•˜λ‹€λ©΄ ν…ŒμŠ€νŠΈλ₯Ό λ§ˆμ € μž‘μ„±ν•΄ μ£Όμ‹œλ©΄ 쒋을 것 κ°™μ•„μš”

Sign up for freeto 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.

2 participants

@jeounpar@testrace