Skip to content

[숫자 야구 게임] 장대영 미션 제출합니다.#4

Open
hururu1234 wants to merge 16 commits intogdgoc-skhu-missions:hururu1234from
hururu1234:main
Open

[숫자 야구 게임] 장대영 미션 제출합니다.#4
hururu1234 wants to merge 16 commits intogdgoc-skhu-missions:hururu1234from
hururu1234:main

Conversation

@hururu1234
Copy link
Copy Markdown

어려웠던 점
-코틀린을 처음 접해서 코드를 이해하는데 어려움을 겪었습니다.
-객체 지향적, 캡슐화 코드에 적용하고 이해하는데 어려움을 겪었습니다.
-아키텍처 디자인이라는 개념이 어려웠습니다.

궁금한 점

Copy link
Copy Markdown
Collaborator

@HanHyunsoo HanHyunsoo left a comment

Choose a reason for hiding this comment

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

느낀점

  • 코틀린 문법을 잘 몰라서 문법에 대한 조언 드리기 힘들다고 먼저 말씀 드릴 수 있을 것같습니다. 양해 주시면 감사하겠습니다.
    • object 개념이 되게 신기하네요 내부적으로 어떻게 동작해서 싱글톤 패턴을 지킬 수 있는지 저도 한번 공부해봐야겠습니다 ㅎ
  • MVC 패턴으로 구분한 것이 좋네요. 역할이 애매한 클래스도 있으니 각 레이어에 맞게 재배치하시면 좋을 것 같습니다.
  • 테스트코드를 작성해서 성공, 실패 케이스를 모두 테스트하면 완성도있는 코드에 가까워질 것 같습니다! 한번 시도해보세요~

private val inputView: Input,
private val outputView: Output,
) {
private var user = User()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. 모델에 해당하는 데이터들이 바뀌지 않기 때문에 val을 쓰시는게 더 좋을 것 같습니다.

  2. 컨트롤러가 여러개 만들어진다면 그만큼 모델들도 만들어지기 때문에 객체간의 결합도를 줄이는 방법을 고려해보세요.

package baseball.util

object Constants {
const val START_MESSAGE = "숫자 야구 게임을 시작합니다."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

각 변수들에 대한 타입 지정을 하시는 게 좋을 것 같습니다. val 키워드가 값을 변경하지 않더라도 명시해두면 가독성이 더 높아질 것 같아요.

import baseball.util.Validator.validateNumber
import camp.nextstep.edu.missionutils.Console

class Input {
Copy link
Copy Markdown
Collaborator

@HanHyunsoo HanHyunsoo Apr 1, 2024

Choose a reason for hiding this comment

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

Input 클래스의 역할은 입력을 처리하는데 해당 역할을 컨트롤러가 수행하는게 MVC 패턴에 더 맞지 않을까요?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

입력의 역할은 Controller만 하는 줄 알았는데 제가 잘 못 알고 있던 것 같습니다. 그대로 가시면 될 것 같습니다.

}

fun printResultMessage(ball: Int, strike: Int) { //매칭 결과 문구 출력
when {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

각 케이스별로 println을 쓸 수 있지만 case문을 통해 문자열을 반환해서 println문 한번만 쓰면 좀더 가독성잇게 바뀔 수 있을 것 같습니다.


fun generateNumber() {
val number = mutableListOf<Int>()
while(number.size < NUMBER_SIZE) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

리스트 대신 다른 자료구조로 시간복잡도를 개선할 수 있을것같아요.

@hangillee hangillee changed the base branch from main to hururu1234 April 3, 2024 08:08
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.

4 participants