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 4] πŸ’£μ§€λ’°μ°ΎκΈ°πŸ’₯ λ¦¬νŒ©ν„°λ§ #492

Open
wants to merge 47 commits into
base: y2gcoder
Choose a base branch
from

Conversation

y2gcoder
Copy link

μ•ˆλ…•ν•˜μ„Έμš” λ‚¨μ€€λ‹˜!

μ˜€λžœλ§Œμ— μΈμ‚¬λ“œλ¦¬κ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€πŸ˜…

ν¬λ¦¬μŠ€λ§ˆμŠ€λŠ” 잘 λ³΄λ‚΄μ…¨λŠ”μ§€μš”?πŸŽ„

λ§ˆμ§€λ§‰ 단계닀 λ³΄λ‹ˆ κ·Έλ™μ•ˆ λ°°μ› λ˜ κ±Έ μ μš©ν•΄λ³΄κ³ μž λ…Έλ ₯ν–ˆμŠ΅λ‹ˆλ‹€!

항상 μ–‘μ§ˆμ˜ ν”Όλ“œλ°± μ£Όμ‹œλŠ” λ‚¨μ€€λ‹˜κ»˜ κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€πŸ‘

ν¬κΈ°ν•˜μ§€ μ•Šκ³  λ§ˆλ¬΄λ¦¬κΉŒμ§€ μ—΄μ‹¬νžˆ ν•΄λ³΄κ² μŠ΅λ‹ˆλ‹€!

κ°μ‚¬ν•©λ‹ˆλ‹€

μ–‘μ˜κ·Ό 올림

- open() λ©”μ„œλ“œ κ°„μ†Œν™”: findAllShouldOpen()으둜 μ±…μž„ 이전
- findAllShouldOpen(): BFSλ₯Ό 톡해 μ—΄μ–΄μ•Ό ν•  Set<Location> 계산
- applyOpen(): Set<Location>을 인덱슀 기반 Set 으둜 λ³€κ²½ && κ°€λ³€ 리슀트둜 λ³€κ²½ν•΄μ„œ 계산 ν›„ λΆˆλ³€ 리슀트둜 λ°˜ν™˜ν•¨μœΌλ‘œμ¨ μ„±λŠ₯ ν–₯상
@namjackson
Copy link

μ•„λ¬΄λž˜λ„ λ¦¬νŒ©ν„°λ§ κ³Όμ •μ΄λΌμ„œ, 크게 μ½”λ©˜νŠΈ λ“œλ¦΄λΆ€λΆ„μ΄ μ—†μ„κ±°κ°™μ•„μš” :)
μ΄λŒ€λ‘œ 마무리 ν•˜μ‹œλ €λ©΄ κ·Έλƒ₯ λ¦¬λ·°μš”μ²­ μ£Όμ‹œκ±°λ‚˜, 머지 ν•˜λ„λ‘ν• κ²Œμš” :)
μ½”λ“œ μ •λ¦¬ν•˜μ…”λ„ 되고, μΆ”κ°€λ‘œ κΆκΈˆν•œμ μžˆμœΌμ‹œλ©΄ μ½”λ©˜νŠΈ 달아주셔도 μ’‹μ•„μš” !

Copy link

@namjackson namjackson left a comment

Choose a reason for hiding this comment

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

μ•ˆλ…•ν•˜μ„Έμš” μ˜κ·Όλ‹˜! μƒˆν•΄λ³΅ 많이 λ°›μœΌμ„Έμš”!
개인적으둜 μ—°μ΄ˆμ— 일정이 λ°”μ˜λ‹€ λ³΄λ‹ˆκΉŒ ν”Όλ“œλ°±μ΄ λŠ¦μ—ˆλ„€μš” :)
지뒰찾기 λ§ˆμ§€λ§‰ 단계 κ³ μƒλ§ŽμœΌμ…¨μŠ΅λ‹ˆλ‹€!
μ½”λ©˜νŠΈ μ°Έκ³ ν•΄μ£Όμ„Έμš”!

@@ -0,0 +1,13 @@
package tdd.minesweeper.domain

Choose a reason for hiding this comment

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

개인적으둜 가독성을 μœ„ν•΄ domain νŒ¨ν‚€μ§€ λ‚΄μ—μ„œλ„
κΈ°λŠ₯ λ“±μœΌλ‘œ λ¬Άμ–΄μ„œ νŒ¨ν‚€μ§€λ₯Ό 관리해봐도 μ’‹μ„κ±°κ°™μ•„μš” :)
cellκ΄€λ ¨ 객체λ₯Ό λͺ¨μ•„λ³΄λŠ”κ±΄ μ–΄λ–¨κΉŒμš”?

Comment on lines +4 to +12
val adjacentMines: AdjacentMines?

fun isOpen(): Boolean

fun hasMine(): Boolean

fun open(): Cell

fun isExpandableToAdjacent(): Boolean

Choose a reason for hiding this comment

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

Cell을 μΈν„°νŽ˜μ΄μŠ€ 둜 λΆ„λ¦¬ν•˜μ…§λ„€μš”!
MineCellμ—μ„œλŠ” adjacentMinesλŠ” null μΌμˆ˜λ°–μ— μ—†κ³ ,
open, isExpandableToAdjacent λ˜ν•œ ClosedCellμ—μ„œλ§Œ ν•„μš”ν•œ ν•¨μˆ˜μ΄κΈ°λ„ν•΄μš” :)
객체지ν–₯ 원칙쀑 μΈν„°νŽ˜μ΄μŠ€ 뢄리 원칙에 μ–΄κΈ‹λ‚ μˆ˜λ„ μžˆλ‹€λŠ” 생각이 λ“€μ–΄μš”,
더 μž‘μ€ λ‹¨μœ„λ‘œ μΈν„°νŽ˜μ΄μŠ€λ₯Ό λΆ„λ¦¬ν•΄λ³Όμˆ˜ μžˆμ„κ±°κ°™μ•„μš”!
(ν•˜μ§€λ§Œ μ–Έμ œλ‚˜, trade-off λΉ„μš©μ΄ λ“œλŠ”κ±΄ μ–΄μ©”μˆ˜ 없을거 κ°™μ•„μš”!
였히렀 μ‘°κΈˆλ” λ³΅μž‘ν•΄μ§ˆμˆ˜ μžˆλ‹€λŠ” 단점이 μžˆμ–΄μš”!
λ³΅μž‘ν•˜μ§€ μ•Šκ³ , μΈν„°νŽ˜μ΄μŠ€λ₯Ό λΆ„λ¦¬ν• μˆ˜ μžˆλŠ” 지점을 μ˜κ·Όλ‹˜μ˜ κΈ°μ€€μœΌλ‘œ μž‘μ•„λ³΄λ©΄ μ–΄λ–¨κΉŒμš”:) )

import tdd.minesweeper.domain.strategy.DefaultBoardCellsCreator

@BoardDslMaker
class BoardBuilder(private val boardCellsCreator: BoardCellsCreator = DefaultBoardCellsCreator()) :

Choose a reason for hiding this comment

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

Dsl ν™œμš© πŸ‘

Comment on lines +7 to +9
class DefaultShouldOpenLocationFinder : ShouldOpenLocationFinder {
override fun findAllShouldOpen(
board: Board,

Choose a reason for hiding this comment

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

Board의 openμ—μ„œ μ—°κ΄€λœ Cell κ΄€λ ¨ 뢀뢄을 뢄리해 μ£Όμ…¨λ„€μš” πŸ‘
Boardμ—μ„œλ„ ShouldOpenLocationFinderλ₯Ό μ˜μ‘΄ν•˜κ³ μžˆκ³ ,
ShouldOpenLocationFinderμ—μ„œλ„ Boardλ₯Ό μ˜μ‘΄ν•˜κ³  μžˆμ–΄μš” :)
Board와 ShouldOpenLocationFinderλŠ” 결합도가 λ†’λ‹€κ³  λ³Όμˆ˜λ„ μžˆμ„κ±° κ°™μ•„μš” :)
μ–‘λ°©ν–₯ μ˜μ‘΄μ„±μ€ 가독성 μΈ‘λ©΄μ΄λ‚˜, μœ μ§€λ³΄μˆ˜ μΈ‘λ©΄μ—μ„œ μ–΄λ €μšΈμˆ˜ μžˆμ–΄μš”

boardκ°€ μ•„λ‹Œ Cellsλ₯Ό λ°›μ•„μ„œ μ²˜λ¦¬ν•˜λ„λ‘ μˆ˜μ •ν• μˆ˜ μžˆμ„κ±° κ°™μ•„μš”

val allLocations = createAllLocations(area)

// 지뒰 μœ„μΉ˜ κ΅¬ν•˜κΈ°
val mineLocations = calculateMineLocations(allLocations, inputManualMineLocations, countOfMines)

Choose a reason for hiding this comment

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

calculateMineLocationsλŠ” λΆ„λ¦¬ν•΄λ³Όμˆ˜ μžˆμ§€ μ•Šμ„κΉŒμš”?
DefaultBoardCellsCreator의 κ΄€μ‹¬μ‚¬λŠ” MineLocations μΌκ±°κ°™μ•„μš”
MineLocations이 inputManual인지, 랜덀 locationμΈμ§€λŠ” λͺ°λΌλ„
Cells을 λ§Œλ“œλŠ”λ° 영ν–₯이 μ—†μ§€λŠ” μ•Šμ„κΉŒμš”?

val closedCells = createMinePlantedCells(allLocations, mineLocations)

// 지뒰 인접 μœ„μΉ˜ ν‘œμ‹œ
val updatedCells = markOfAdjacentMines(closedCells, allLocations, mineLocations)

Choose a reason for hiding this comment

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

이미 closedCellsμ—λŠ” allLocations, mineLocations에 λŒ€ν•œ 정보가 μžˆμ§€ μ•Šλ‚˜μš”?
지뒰 인접 μœ„μΉ˜ ν‘œμ‹œ κΈ°λŠ₯에 3개의 λ¦¬μŠ€νŠΈκ°€ ν•„μš”ν• κΉŒμš”? :)

import io.kotest.core.spec.style.BehaviorSpec
import io.kotest.matchers.shouldBe

class AdjacentMinesTest : BehaviorSpec({

Choose a reason for hiding this comment

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

μƒˆλ‘­κ²Œ TDD둜 λ‹€μ‹œν•œλ²ˆ μž‘μ„±ν•˜μ‹ λΆ€λΆ„μ€ μ–΄λ– μ…¨λ‚˜μš”?

μ €λŠ” TDDλ₯Ό 처음 λ„μž…ν•˜λ‹€λ³΄λ©΄ μ•„λ¬΄λž˜λ„ 처음 μž‘μ„±ν•œ ν…ŒμŠ€νŠΈμΌ€μ΄μŠ€μ—λŒ€ν•œ ν…ŒμŠ€νŠΈ μ½”λ“œλ₯Ό λ¨Όμ € μž‘μ„±ν•˜κ³ ,
이에 λ§Œμ‘±ν•˜κΈ°μœ„ν•΄ κ΅¬ν˜„ν•˜λ‹€λ³΄λ‹ˆ, 섀계가 μ–΄κΈ‹λ‚˜κ±°λ‚˜ κΌ¬μ—¬μ„œ, μ–΄λ €μ› λ˜ 기얡이 λ‚˜λ„€μš”,

μƒˆλ‘œ ν•œλ²ˆ μž‘μ„±ν•˜κ²Œλ˜λ‹ˆ 기쑴에 μ–΄λŠμ •λ„ 도메인과 섀계에 λŒ€ν•œ 기반이 μŒ“μ—¬μ„œ
μ‘°κΈˆλ” μžμ—°μŠ€λŸ½κ²Œ TDDλ₯Ό ν• μˆ˜ μžˆμ—‡λ˜κ±° κ°™μ•„μš” :)

@y2gcoder
Copy link
Author

y2gcoder commented Jan 17, 2025

μ•„λ¬΄λž˜λ„ λ¦¬νŒ©ν„°λ§ κ³Όμ •μ΄λΌμ„œ, 크게 μ½”λ©˜νŠΈ λ“œλ¦΄λΆ€λΆ„μ΄ μ—†μ„κ±°κ°™μ•„μš” :) μ΄λŒ€λ‘œ 마무리 ν•˜μ‹œλ €λ©΄ κ·Έλƒ₯ λ¦¬λ·°μš”μ²­ μ£Όμ‹œκ±°λ‚˜, 머지 ν•˜λ„λ‘ν• κ²Œμš” :) μ½”λ“œ μ •λ¦¬ν•˜μ…”λ„ 되고, μΆ”κ°€λ‘œ κΆκΈˆν•œμ μžˆμœΌμ‹œλ©΄ μ½”λ©˜νŠΈ 달아주셔도 μ’‹μ•„μš” !

@namjackson

λ‚¨μž¬λ‹˜ μƒˆν•΄ 볡 많이 λ°›μœΌμ‹­μ‡Ό :)
확인이 λŠ¦μ–΄μ„œ μ£„μ†‘ν•©λ‹ˆλ‹€!

μ—­μ‹œ κΈ°λŒ€λ₯Ό 저버리지 μ•Šκ³  μ–‘μ§ˆμ˜ μ½”λ©˜νŠΈλ₯Ό λ‚¨κ²¨μ£Όμ…¨κ΅°μš”... κ°μ‚¬ν•©λ‹ˆλ‹€πŸ˜Š

λ§ˆμ§€λ§‰ ν”Όλ“œλ°±μ€ λ¨Έμ§€ν•΄μ£Όμ‹œλ©΄ ν¬ν¬ν•œ 제 λ ˆν¬μ—μ„œ 개인적으둜 λ°˜μ˜ν•΄λ³΄κ² μŠ΄λ‹€!

벌써 μ½”μŠ€κ°€ λλ‚œ 지도 ν•œ 달이 λ‹€ λ˜μ–΄ κ°€λŠ”λ° λ‚¨μž¬λ‹˜μ„ 계속 λΆ™μž‘μ•„λ‘λŠ” 것 κ°™μ•„ μ£„μ†‘ν•©λ‹ˆλ‹€πŸ₯Ή

κ·Έλ™μ•ˆ μ§€μ €λΆ„ν•œ 제 μ½”λ“œ λ΄μ£Όμ…”μ„œ λ„ˆλ¬΄ κ°μ‚¬ν–ˆμŠ΅λ‹ˆλ‹€!

λ‚¨μž¬λ‹˜κ»˜ 배운 것 κΉŒλ¨Ήμ§€ μ•Šκ³  계속 μ‚¬μš©ν•΄μ„œ 쒋은 μ½”λ“œλ₯Ό μž‘μ„±ν•˜κΈ° μœ„ν•΄ λ…Έλ ₯ν•˜κ² μŠ΅λ‹ˆλ‹€ πŸ‘

@y2gcoder y2gcoder requested a review from namjackson January 17, 2025 07:39
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