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

πŸš€ 5단계 - μžλ™μ°¨ κ²½μ£Ό(λ¦¬νŒ©ν„°λ§) #1742

Open
wants to merge 11 commits into
base: aimbe
Choose a base branch
from

Conversation

Aimbe
Copy link

@Aimbe Aimbe commented Nov 23, 2024

μ•ˆλ…•ν•˜μ„Έμš” μˆ˜ν˜„λ‹˜!
이번 μŠ€ν…μ€ view/domain클래슀의 μ±…μž„λΆ„λ¦¬μ™€ μ΄μ „λ‹¨κ³„μ—μ„œ ν”Όλ“œλ°± μ£Όμ…¨λ˜
리뷰 λ°”νƒ•μœΌλ‘œ λ³΅μŠ΅ν–ˆμŠ΅λ‹ˆλ‹€.
ν•˜λ©΄μ„œ κ°μ‚¬μ˜€ μ‚¬μ„œ 보고 μžˆλŠ”λ°, οΏ½οΏ½ν™•μ‹€νžˆ 이전에 λ΄€μ„λ•Œλž‘ λ‹€λ₯΄κ²Œ λ‹€κ°€μ˜€λŠ”κ±° κ°™μ•„μš”. λ§ˆμ§€λ§‰ 단계도 ν”Όλ“œλ°± 잘 λΆ€νƒλ“œλ €μš”!

Copy link
Member

@wisemuji wisemuji left a comment

Choose a reason for hiding this comment

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

μ•ˆλ…•ν•˜μ„Έμš” μ •ν˜Έλ‹˜! κ°μ‚¬μ˜€λ₯Ό λ‹€μ‹œ 읽고 κ³„μ‹œλŠ”κ΅°μš”! 도움이 λ˜μ—ˆλ‹€λ‹ˆ κΈ°μ©λ‹ˆλ‹€ πŸ™‚

이전에 λΉ„ν•΄μ„œ 메세지λ₯Ό μ „λ‹¬ν•˜λŠ” 과정이 더 "λŠ₯동적인" 객체의 μ±…μž„μœΌλ‘œ 이어진 것 κ°™μ•„μš”.
λ§ˆμ§€λ§‰ 단계인 만큼 도전적인 μ½”λ©˜νŠΈλ₯Ό λͺ‡ 가지 λ‹¬μ•˜μŠ΅λ‹ˆλ‹€.

κΆκΈˆν•œ μ μ΄λ‚˜ λ…Όμ˜ν•˜κ³  싢은 λ‚΄μš©μ΄ 있으면 μ–Έμ œλ“  μ•Œλ €μ£Όμ„Έμš”!

@@ -20,9 +22,9 @@ class PlayGame(private val racingCars: RacingCars, private val attempts: Int) {
fun play() {
repeat(attempts) {
racingCars.moveAll { (0..9).random() }
printRoundResult(racingCars.getPositionsWithName())
printRoundResult(racingCars)
Copy link
Member

Choose a reason for hiding this comment

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

λ§ˆμ§€λ§‰ 단계인 만큼 μ’€ 더 κ°œμ„ ν•΄λ³Ό 수 μžˆλŠ” μ—¬λŸ¬ 아이디어λ₯Ό μ œμ‹œν•˜κ³  μ‹Άμ–΄μš” πŸ™‚

ResultView ν˜ΈμΆœμ„ μ΅œλŒ€ν•œ 쀄여보면 μ–΄λ–¨κΉŒμš”?

μš°λ¦¬κ°€ ν”νžˆ μ›Ή ν”„λ‘œκ·Έλž¨μ—μ„œ μ„œλ²„μ™€ ν΄λΌμ΄μ–ΈνŠΈ 간에 μ†Œν†΅ν•˜λŠ”κ±Έ 생각해보면
μ„œλ²„μ™€ ν΄λΌμ΄μ–ΈνŠΈκ°€ μ„œλ‘œ μš”μ²­κ³Ό 응닡을 μ£Όκ³ λ°›λŠ” 과정은 λͺ¨λ‘ λΉ„μš©μž…λ‹ˆλ‹€. μ΄λŸ¬ν•œ λΉ„μš©μ„ μ€„μ΄λŠ” 것이 μ›Ή ν”„λ‘œκ·Έλž˜λ°μ—μ„œ μ€‘μš”ν•˜κ²Œ 여겨지기도 ν•©λ‹ˆλ‹€.

또 μ§€κΈˆμ€ λ‹¨μˆœν•œ μ½˜μ†” ν”„λ‘œκ·Έλž¨μ΄μ§€λ§Œ, λ‚˜μ€‘μ— λ·°κ°€ μ•ˆλ“œλ‘œμ΄λ“œ μ•±μœΌλ‘œ λ°”λ€λ‹€λ˜μ§€, μ›ΉνŽ˜μ΄μ§€ λ“±μœΌλ‘œ 바뀐닀고 ν•˜λ©΄ μ΄λŸ¬ν•œ 호좜이 λͺ¨λ‘ λΉ„μš©μ΄ λ©λ‹ˆλ‹€.

class CarPositionFormatter {
companion object {
fun formatCarPosition(car: RacingCar): String {
return "μžλ™μ°¨ ${car.name} : ${formatPosition(car.position)}"
Copy link
Member

Choose a reason for hiding this comment

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

λ·° μš”κ΅¬ 사항에 μ˜μ‘΄ν•˜κ³  μžˆλŠ” 이 둜직이 domain νŒ¨ν‚€μ§€μ— μžˆλŠ” 것이 μ μ ˆν• κΉŒμš”?

MVC νŒ¨ν„΄ 기반으둜 λ¦¬νŒ©ν† λ§ν•΄ view νŒ¨ν‚€μ§€μ˜ 객체가 domain νŒ¨ν‚€μ§€ 객체에 μ˜μ‘΄ν•  수 μžˆμ§€λ§Œ, domain νŒ¨ν‚€μ§€μ˜ κ°μ²΄λŠ” view νŒ¨ν‚€μ§€ 객체에 μ˜μ‘΄ν•˜μ§€ μ•Šλ„λ‘ κ΅¬ν˜„ν•œλ‹€.

Copy link
Author

Choose a reason for hiding this comment

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

μ•„λ¬΄λž˜λ„ domain에 있긴 μ•ˆλ§žκ³  view에 μžˆκΈ°μ—λ„ μ• λ§€ν•΄μ„œ util νŒ¨ν‚€μ§€ 생성 ν›„ μ΄λ™μ‹œμΌ°μŠ΅λ‹ˆλ‹€! γ…Žγ…Ž

package misson.car.domain

// μ½”ν‹€λ¦° λ¬Έλ²•μ—μ„œ position을 private으둜 ν•˜μ§€ μ•Šμ•„λ„ λ‚΄λΆ€μ μœΌλ‘œλŠ” getter둜 μ ‘κ·Ό
class RacingCar(val name: String = "뢕뢕이", var position: Int = 0) {
Copy link
Member

Choose a reason for hiding this comment

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

ν˜„μž¬λŠ” position이 privateν•˜μ§€ μ•ŠκΈ° λ•Œλ¬Έμ— μ™ΈλΆ€μ—μ„œ position 값을 λ§ˆμŒλŒ€λ‘œ μˆ˜μ •ν•  수 μžˆμ–΄μš”.

val car = RacingCar()
car.position = 123

μ–΄λ–»κ²Œ κ°œμ„ ν•΄λ³Ό 수 μžˆμ„κΉŒμš”?
https://kotlinlang.org/docs/properties.html#getters-and-setters

Copy link
Member

Choose a reason for hiding this comment

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

"뢕뢕이"λŠ” λ„ˆλ¬΄ κ·€μ—½μ§€λ§Œ(γ…‹γ…‹γ…‹) ν…ŒμŠ€νŠΈ νŽΈμ˜μ„±μ„ μœ„ν•΄ λ§Œλ“€μ–΄μ§„ κ°’μ΄λ―€λ‘œ ν”„λ‘œλ•μ…˜ μ½”λ“œμ— μΆ”κ°€λ˜κΈ°μ—λŠ” μ ν•©ν•˜μ§€ μ•Šμ€ 것 κ°™μ•„μš”.

assertThrows<IllegalArgumentException> {
RacingCar("1234567")
}
assertThat(assertThrows<IllegalArgumentException> { RacingCar("1234567") }.message)
Copy link
Member

Choose a reason for hiding this comment

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

RacingCar의 position 값을 μ΄ˆκΈ°ν™”ν•œλ‹€λŠ” 것을 λͺ…μ‹œμ μœΌλ‘œ λ“œλŸ¬λ‚΄κΈ° μœ„ν•΄ named argumentsλ₯Ό ν™œμš©ν•˜μ‹œλ©΄ μ–΄λ–¨κΉŒμš”?

RacingCar(position = "1234567")

이 외에도 named argumentsλ₯Ό ν™œμš©ν•  곳이 μžˆλ‚˜μš”? ν”„λ‘œμ νŠΈ μ „λ°˜μ μœΌλ‘œ 적용될 수 μžˆλŠ” 변경사항인 것 κ°™μ•„μš”!

"3, 0",
"2, 0",
)
fun `Param 값에 따라 μžλ™μ°¨ 그룹이 μ΄λ™ν•œλ‹€`(
Copy link
Member

Choose a reason for hiding this comment

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

ν…ŒμŠ€νŠΈλͺ…을 톡해 μ–΄λ–€ 것을 ν…ŒμŠ€νŠΈν•˜κ³ μž ν•˜λŠ” 것이 μ œλŒ€λ‘œ λ“œλŸ¬λ‚˜μ§€ μ•ŠλŠ” 것 κ°™μ•„μš”. ν…ŒμŠ€νŠΈλͺ…을 μž‘μ„±ν•˜μ‹€ λ•Œμ—λŠ”

  1. κ²€μ¦ν•˜κ³ μž ν•˜λŠ” λ‘œμ§μ„ λͺ…ν™•ν•˜κ²Œ μ •ν•˜κ³  (검증이 ν•„μš”ν•œ 둜직이 두 개 이상이면 ν•„μš”μ— 따라 또 λ‹€λ₯Έ ν•¨μˆ˜λ‘œ λΆ„ν• ν•œλ‹€)
  2. 그것을 ν•¨μˆ˜λͺ…μœΌλ‘œ λ“œλŸ¬λ‚΄λ³΄λ©΄ μ–΄λ–¨κΉŒμš”?

μ΄μƒμ μœΌλ‘œλŠ” κΈ°λŠ₯ μš”κ΅¬ μ‚¬ν•­μœΌλ‘œ μ •λ¦¬ν•˜μ‹  λ¬Έμ„œμ˜ μ‹œλ‚˜λ¦¬μ˜€κ°€ κ·ΈλŒ€λ‘œ ν…ŒμŠ€νŠΈ μ‹œλ‚˜λ¦¬μ˜€λ‘œλ„ 이어지면 μ’‹μŠ΅λ‹ˆλ‹€ πŸ™‚

"3, '---'",
"5, '-----'",
)
fun `positionλ§ˆλ‹€ -λ₯Ό 뢙인닀`(
Copy link
Member

Choose a reason for hiding this comment

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

λ‹€μŒ μš”κ΅¬ 사항을 λ‹€μ‹œ ν•œ 번 고렀해보면 μ–΄λ–¨κΉŒμš”~?

λͺ¨λ“  λ‘œμ§μ— λ‹¨μœ„ ν…ŒμŠ€νŠΈλ₯Ό κ΅¬ν˜„ν•œλ‹€. 단, UI(System.out, System.in) λ‘œμ§μ€ μ œμ™Έ
핡심 λ‘œμ§μ„ κ΅¬ν˜„ν•˜λŠ” μ½”λ“œμ™€ UIλ₯Ό λ‹΄λ‹Ήν•˜λŠ” λ‘œμ§μ„ κ΅¬λΆ„ν•œλ‹€.
UI λ‘œμ§μ„ InputView, ResultView와 같은 클래슀λ₯Ό μΆ”κ°€ν•΄ λΆ„λ¦¬ν•œλ‹€.

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.

2 participants