-
Notifications
You must be signed in to change notification settings - Fork 156
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
[4기 - 강병곤] 1~2주차 과제 : 계산기 구현 미션 제출합니다. #189
base: Curry4182
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.
병곤님 과제 하느라 수고하셨습니다!
1주차보다 많이 발전하신 것 같아요.
New팀에서도 이렇게 적극적으로 임하시면 금방 성장 하실거에요 :)
import calcproject.view.CalcInput; | ||
import calcproject.view.CalcOutput; | ||
|
||
public class CalcManagerDependencyInjectionContainer { |
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.
DependencyInjectionContainer라는 네이밍은 너무 스프링 기술에 치중되어 있는 느낌이 드는데요,
실제로 스프링의 기술을 구현해서 사용하는 것이 아니라면, 다른 이름이 좋아보여요
src/main/java/calcproject/Main.java
Outdated
CalcExpressionTokenizer calcExpressionTokenizer = new CalcExpressionTokenizer(); | ||
Calculator calculator = new Calculator(calcExpressionTokenizer); | ||
|
||
CalcManager calcManager = new CalcManager(calcResultRecordRepository, calcConsoleView, calcConsoleView, | ||
calculator); | ||
CalcManagerViewFactory calcManagerViewFactory = new ConsoleViewCalcManagerViewFactory(); | ||
CalcResultRecordRepositoryFactory calcResultRecordRepositoryFactory = new InMemoryCalcResultRecordRepositoryFacotry(); | ||
|
||
CalcManagerDependencyInjectionContainer calcManagerDependencyInjectionContainer = | ||
new CalcManagerDependencyInjectionContainer(calcResultRecordRepositoryFactory, calcManagerViewFactory, | ||
calculator); |
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.
모든 객체가 main을 통해서 생성되고 있어서, main과 강한 의존성을 가지겠네요.
구조를 짜고 계층형으로 분리하면 좀 더 좋을 것 같아요.
@@ -12,9 +12,9 @@ public class MemoryCalcResultRecordRepository implements CalcResultRecordReposit | |||
private Map<Integer, CalcResultRecordModel> calcMap; |
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을 쓰신 이유가 있나요?
@@ -15,7 +15,7 @@ public enum Command { | |||
|
|||
public static Command valueOf(int choiceNum) { | |||
return Arrays.stream(values()) | |||
.filter(value -> value.equals(choiceNum)) | |||
.filter(value -> value.getCmdIdx() == choiceNum) |
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.
비교하는 메서드를 따로 만드는건 어떨까요?
@@ -15,7 +15,7 @@ public enum Command { | |||
|
|||
public static Command valueOf(int choiceNum) { | |||
return Arrays.stream(values()) | |||
.filter(value -> value.equals(choiceNum)) | |||
.filter(value -> value.getCmdIdx() == choiceNum) | |||
.findAny() | |||
.orElse(CALCULATE.EXIT); |
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.
CALCULATE.EXIT는 사용자 의도로 인해 종료한다는 느낌인데요
강제종료를 의도하신거라면 TERMINATE는 어떠신가요?
if (stackPeekOPerator == Operator.UnSupportedOp) { | ||
return null; | ||
} |
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.
List을 반환값으로 가지고 있는데 null을 반환하는 이유가 있을까요?
for (int i = 0; i < postFixNotationTokens.size(); i++) { | ||
String token = postFixNotationTokens.get(i); |
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.
for each를 사용해도 되겠네요
double operand2 = stack.pop(); | ||
double operand1 = stack.pop(); |
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.
stack이 비어있다면 어떻게 되나요?
private static Stream<Arguments> expressionProvider() { | ||
return Stream.of( | ||
Arguments.of("1 + 2 * 3 / 4", Arrays.asList("1", "+", "2", "*", "3", "/", "4")), | ||
Arguments.of("10 * 4 / 1", Arrays.asList("10", "*", "4", "/", "1")), | ||
Arguments.of("4 * 3 / 2 - 1", Arrays.asList("4", "*", "3", "/", "2", "-", "1")) | ||
); | ||
} |
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.
MethodSource를 사용해보셔군요!
그런데 테스트에 어떤 값을 넣었는지 확인하기는 좀 불편한 것 같아요
for (int i = 0; i < expressionList.size(); i++) { | ||
String expression = expressionList.get(i); | ||
Double calcRsult = calcResultList.get(i); | ||
|
||
CalcResultRecordModel calcResultRecord = new CalcResultRecordModel(expression, calcRsult); | ||
this.calcResultRecordRepository.saveCalcResultRecord(calcResultRecord); | ||
expectedCalcRecords.add(calcResultRecord); |
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.
이런 코드가 테스트 코드에 들어가게 되면, CalcResultRecordModel 코드가 변경되면 전혀 상관없는 MemoryCalcResultRecordRepository의 테스트 코드가 깨지게 되겠네요
📌 과제 설명
👩💻 요구 사항과 구현 내용
-> 애플리케이션이 동작하는 동안 데이터베이스 외에 데이터를 저장할 수 있도록 개발 하였습니다.
✅ 피드백 반영사항
✅ PR 포인트 & 궁금한 점