Skip to content

Commit bfe6e67

Browse files
committed
Revert "step4 - [클로드코드리뷰] LinesFactoryBean->LinesFactory네이밍 변경 Bean은 Spring의 FactoryBean 패턴과 혼동됨"
This reverts commit 975928a.
1 parent 975928a commit bfe6e67

File tree

7 files changed

+31
-26
lines changed

7 files changed

+31
-26
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package engine;
22

33
import nextstep.ladder.domain.Line;
4+
import nextstep.ladder.strategy.LineStrategy;
45

56
import java.util.List;
67

78

89
public interface LinesCreator {
10+
void generateLine(int participantCnt, int maxLadder, LineStrategy lineStrategy);
911
List<Line> getLines();
1012
}

src/main/java/factory/LinesFactory.java

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package factory;
2+
3+
import engine.LinesCreator;
4+
import nextstep.ladder.domain.NextStepLines;
5+
import nextstep.ladder.strategy.LineStrategy;
6+
7+
public class LinesFactoryBean {
8+
9+
public static LinesCreator createNextStepLadderFactory(int size, int maxLadder, LineStrategy lineStrategy) {
10+
NextStepLines nextStepLines = new NextStepLines();
11+
nextStepLines.generateLine(size, maxLadder, lineStrategy);
12+
return nextStepLines;
13+
}
14+
15+
}

src/main/java/nextstep/ladder/controller/LadderController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package nextstep.ladder.controller;
22

33
import engine.LinesCreator;
4-
import factory.LinesFactory;
4+
import factory.LinesFactoryBean;
55
import nextstep.ladder.domain.LadderExecutor;
66
import nextstep.ladder.domain.ExecuteResult;
77
import nextstep.ladder.domain.LadderResult;
@@ -29,7 +29,7 @@ public void startLadder() {
2929

3030
ExecuteResult executeResult = new ExecuteResult(participants.size(), executeResultStr);
3131

32-
LinesCreator linesCreator = LinesFactory.createNextStepLines(participants.size(), maxLadder, new LadderLineStrategy());
32+
LinesCreator linesCreator = LinesFactoryBean.createNextStepLadderFactory(participants.size(), maxLadder, new LadderLineStrategy());
3333

3434
LadderExecutor ladderExecutor = new LadderExecutor(linesCreator, participants);
3535
MachingResult machingResult = ladderExecutor.play();

src/main/java/nextstep/ladder/domain/NextStepLines.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
public class NextStepLines implements LinesCreator {
1010
private final List<Line> lines;
1111

12-
public NextStepLines(int participantCnt, int maxLadder, LineStrategy lineStrategy) {
13-
this.lines = new ArrayList<>();
14-
generateLine(participantCnt, maxLadder, lineStrategy);
12+
public NextStepLines() {
13+
this(new ArrayList<Line>());
1514
}
1615

1716
public NextStepLines(ArrayList<Line> lines) {
1817
this.lines = new ArrayList<>(lines);
1918
}
2019

21-
private void generateLine(int participantCnt, int maxLadder, LineStrategy lineStrategy) {
20+
public void generateLine(int participantCnt, int maxLadder, LineStrategy lineStrategy) {
2221
for (int i = 0; i < maxLadder; i++) {
2322
generateLine(participantCnt, lineStrategy);
2423
}
@@ -29,7 +28,6 @@ private void generateLine(int participantCnt, LineStrategy lineStrategy) {
2928
lines.add(line);
3029
}
3130

32-
@Override
3331
public List<Line> getLines() {
3432
return lines;
3533
}

src/test/java/engine/LinesFactoryTest.java renamed to src/test/java/engine/LinesFactoryBeanTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package engine;
22

3-
import factory.LinesFactory;
3+
import factory.LinesFactoryBean;
44
import nextstep.ladder.domain.LadderExecutor;
55
import nextstep.ladder.domain.MachingResult;
66
import nextstep.ladder.domain.Participants;
@@ -9,11 +9,11 @@
99

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

12-
public class LinesFactoryTest {
12+
public class LinesFactoryBeanTest {
1313

1414
@Test
15-
void createNextStepLines() {
16-
LinesCreator linesCreator = LinesFactory.createNextStepLines(3, 5, new TrueLineStrategy());
15+
void createNextStepLadderFactory() {
16+
LinesCreator linesCreator = LinesFactoryBean.createNextStepLadderFactory(3, 5, new TrueLineStrategy());
1717
Participants participants = new Participants("a,b,c");
1818
LadderExecutor ladderExecutor = new LadderExecutor(linesCreator, participants);
1919
MachingResult machingResult = ladderExecutor.play();

src/test/java/nextstep/ladder/domain/NextStepLinesTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ class NextStepLinesTest {
1010

1111
public static NextStepLines lines() {
1212
LineStrategy lineStrategy = new TrueLineStrategy();
13-
return new NextStepLines(4, 3, lineStrategy);
13+
NextStepLines nextStepLines = new NextStepLines();
14+
nextStepLines.generateLine(4, 3, lineStrategy);
15+
return nextStepLines;
1416
}
1517

1618
@Test
1719
void 세명의참가자만큼_네줄로_사다리_생성() {
1820
LineStrategy lineStrategy = new TrueLineStrategy();
19-
NextStepLines nextStepLines = new NextStepLines(3, 4, lineStrategy);
21+
NextStepLines nextStepLines = new NextStepLines();
22+
nextStepLines.generateLine(3, 4, lineStrategy);
2023

2124
assertThat(nextStepLines.size()).isEqualTo(4);
2225
for (int i = 0; i < nextStepLines.size(); i++) {

0 commit comments

Comments
 (0)