Skip to content
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

계산기(모둠) [STEP 1] Nicholas, Ari #134

Merged

Conversation

leeari95
Copy link
Member

@corykim0829

@Kim-EunsooSilver @leeari95
안녕하세요. 코리~ 이번 프로젝트 피드백 잘부탁드립니다. 😊

이번에 단순히 서로 코드를 비교하며 합치는 작업만 해서 특별히 궁금한 점은 없었습니다.

간단히 코드를 합치면서 고민했던 부분을 적어보았는데 혹시 부족한 점이 있다면 피드백 부탁드립니다! 😁

고민했던 것

  • 주어진 UML 기반으로만 코드를 병합하려고 노력했습니다.
  • CalculatorItemQueue를 LinkedList에서 DoubleStack으로 변경하였습니다. 변경한 이유는 LinkedList보다 간결한 코드로 시간복잡도를 해결할 수 있다고 생각했기 때문입니다.
  • 기존에 CutomView를 활용하여 Label을 추가하던 부분을 Cutom으로 만든 StackView를 추가하는 방식으로 수정하였습니다.
  • 자동 스크롤 해주는 부분 중에 DispatchQueue 메서드를 활용하여 지연을 준 후 스크롤을 해주는 부분을 layoutIfNeeded로 레이아웃을 업데이트 후 스크롤 해주는 방식으로 수정하였습니다.
    • 이 두가지 부분을 통해서 코드 내부 가독성과 간결함을 얻을 수 있었습니다.
  • 기존 코드에는 없던 기능을 추가하여 병합해보았습니다. 계산이 완료되고 난 후 추가적으로 계산을 할 수 있도록 기능을 추가하였습니다.
  • 코딩컨벤션에 맞게 줄바꿈을 수정하였습니다.
  • 코드를 병합하면서 불필요한 파일들이 생겼으나 고민해본 결과 다음 스텝에서 리펙토링을 진행하며 제거하는 것이 맞다고 판단되어 보류했습니다.

궁금했던 것 / 조언이 필요한 부분

  • STEP 1을 진행하면서 개선해야할 점이 보였지만 해당 프로젝트 요구사항에 충실하기 위해서 다음 스텝에서 진행하기로 하고 따로 코드 개선은 하지 않았습니다. 병합하면서 에러가 나는 부분만 최소한으로 수정하고 넘어갔는데 STEP 2에서 개선하여도 괜찮을까요?

- 초기값 0일경우 0, 00 입력 받지 못하게 함
- 초기값이 0일경우 입력된 숫자로 대치
- 사용자의 입력을 changeNumberFormatter 함수를 거쳐 label에 표현
- operand label 값 이외에 별도의 inputedOperand 변수에 입력됨
- 초기 상태에서 연산자 입력시에 무시하도록 개선
- formula 변수 선언
- insertFormual 함수 선언
- resetFormula 함수 선언
- calculate 함수 선언
- CustomStringConvertible 채택
- description 프로퍼티 선언
- CalculatorViewController 의 연산자 버튼의 타이틀과 동일하도록
Kim-EunsooSilver and others added 28 commits November 18, 2021 15:52
- 현재 입력된 값이 0일 경우 guard문으로 대체
- 삭제 이유: NumberFormatter에서 해당 조건을 확인함
- CalculatorItemQueue 수정에 따른 테스트코드 전반적 수정
- 코드 수정에 따른 Formula, ExpressionParser, CalculatorController 전반적 수정
- CustomView인 FormulaStackView 클래스 추가
- addFormula 메소드를 삭제 후 addCurrentFormulaStack 메소드를 추가
- 커스텀뷰를 추가하면서 CalculatorController.insertFormula 메소드도 동작하게 구현
- DispatchQueue로 지연을 주었던 autoScrollDown 메소드 삭제 후 scrollToBottom 메소드 추가
- 계산이 완료되었을 때 hasCalculated를 true로 대입
- 계산이 완료되었을 때 숫자버튼,닷버튼,PlusMinus버튼이 작동하지 않도록 수정
- 계산이 완료되고 clearEntry버튼을 터치 시 모든 계산식이 초기화되게 수정
- 결과값이 Nama일 경우 operator 입력 불가
Copy link

@corykim0829 corykim0829 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!

커멘트 해드린 부분 다음 스텝하면서 바로 수정하시면 될 것 같아요!

다음 브랜치는 Nicholas_Ari_step_0 이런식으로 하면 좋을 것 같아요!

네 개선사항은 step2에서 진행해주세요!

import Foundation
import UIKit

class calculatorHistoryUILbel: UILabel {

Choose a reason for hiding this comment

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

클래스명은 대문자로 시작하는 부분, Label 오타 확인해주세요!
클래스명에서는 끝에 UI까지 안붙이고 Label이라고 하면 충분히 UILabel이라고 유추할 수 있을 것 같아요!

}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")

Choose a reason for hiding this comment

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

여기서 fatalError를 호출하지 않고 super.init 으로 처리해주세요.


private func addCurrentFormulaStack() {
guard let `operator` = operatorLabel.text,
let operand = operandLabel.text else {

Choose a reason for hiding this comment

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

여기 공백이 두개 들어간 것 같아요 확인해주세요!

@corykim0829 corykim0829 merged commit 1fc57f3 into yagom-academy:4-Kim-EunsooSilver Nov 23, 2021
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