# [์šฐ์•„ํ•œํ…Œํฌ์ฝ”์Šค 6๊ธฐ] ํ”„๋ฆฌ์ฝ”์Šค 1์ฃผ์ฐจ ์ˆซ์ž์•ผ๊ตฌ ๋ฏธ์…˜ ํ›„๊ธฐ
Study Repository

[์šฐ์•„ํ•œํ…Œํฌ์ฝ”์Šค 6๊ธฐ] ํ”„๋ฆฌ์ฝ”์Šค 1์ฃผ์ฐจ ์ˆซ์ž์•ผ๊ตฌ ๋ฏธ์…˜ ํ›„๊ธฐ

by rlaehddnd0422

1์ฃผ์ฐจ ๋ฏธ์…˜ - ์ˆซ์ž์•ผ๊ตฌ

 

GitHub - woowacourse-precourse/java-baseball-6

Contribute to woowacourse-precourse/java-baseball-6 development by creating an account on GitHub.

github.com

 

์ง€๋‚œ ์šฐ์•„ํ•œํ…Œํฌ์ฝ”์Šค 5๊ธฐ ์ˆซ์ž์•ผ๊ตฌ ๋ฏธ์…˜๊ณผ ๋™์ผํ•œ ๋ฏธ์…˜์ด์—ˆ๋‹ค. ๋‹ค๋งŒ, ์กฐ๊ธˆ ๋‹ค๋ฅธ ์ ์ด ์žˆ๋‹ค๋ฉด 

  • 'JDK 17 ๋ฒ„์ „์—์„œ ์‹คํ–‰ ๊ฐ€๋Šฅํ•ด์•ผ ํ•œ๋‹ค.' ๋Š” ์ .
  • 5๊ธฐ ์ˆซ์ž์•ผ๊ตฌ ๋ฏธ์…˜์˜ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ(indent depth๋ฅผ 2๋กœ ์ œํ•œ, 3ํ•ญ ์—ฐ์‚ฐ์ž ์‚ฌ์šฉ ์ œํ•œ, ๋ฉ”์†Œ๋“œ๋Š” ํ•œ ๊ฐ€์ง€ ์ผ๋งŒ ํ•˜๋„๋ก ์ œํ•œ)์ด ์—†์–ด์กŒ๋‹ค๋Š” ์ .

 

+ ๋Œ€์‹  ๊ผญ ์ง€์ผœ์•ผ ํ•  ์ปจ๋ฒค์…˜ 4๊ฐ€์ง€๋Š” ๊ฐ€์ด๋“œ๋กœ ์ œ์‹œํ•ด์ฃผ์—ˆ๋‹ค.

 

[JAVA] Google Java Convention, ๊ตฌ๊ธ€ ์ž๋ฐ” ์ฝ”๋“œ ์ž‘์„ฑ๊ทœ์น™์— ๋Œ€ํ•˜์—ฌ

์ฝ”๋”ฉ ์ปจ๋ฒค์…˜

sihyung92.oopy.io

 

์ž๋ฐ” ์ปจ๋ฒค์…˜ ์ค‘์—์„œ ๋‹ค์Œ ๋„ค ๊ฐ€์ง€๋Š” ๋ฐ˜๋“œ์‹œ ์ค€์ˆ˜ํ•˜๋ผ๋Š” ์š”๊ตฌ์‚ฌํ•ญ์ด ์žˆ์—ˆ๋‹ค.

 

1. ๋ธ”๋ก ๋“ค์—ฌ์“ฐ๊ธฐ : ์ค„๋ฐ”๊ฟˆ์„ ํ•˜๊ณ  ๋‚˜๋ฉด ์ตœ์ดˆ ํ–‰๋ณด๋‹ค ์ตœ์†Œ 4์ž๋ฅผ ๋“ค์—ฌ์“ฐ๊ธฐ ํ•˜์ž.

2. ์—ด ์ œํ•œ : ํ•˜๋‚˜์˜ ๋ฌธ์žฅ์€ ์ตœ๋Œ€ 100๊ธ€์ž๋กœ ์ œํ•œํ•œ๋‹ค.

3. ๋“ค์—ฌ์“ฐ๊ธฐ ์ง€์†์€ ์ตœ์†Œ +8 ์ŠคํŽ˜์ด์Šค : indent์˜ depth๊ฐ€ ์ปค์งˆ ๋•Œ +4์ž์˜ ๋“ค์—ฌ์“ฐ๊ธฐ๋ฅผ ํ•˜์ž.

4. ์ˆ˜์ง ๋นˆ ์ค„ : ํด๋ž˜์Šค์˜ ์ฒซ ๋ฒˆ์งธ ๋ฉค๋ฒ„๋‚˜ ์ดˆ๊ธฐํ™” ์•ž์— ์žˆ๋Š” ๋นˆ ์ค„์„ ๊ฐ•์ œํ•˜์ง€ ์•Š๋Š”๋‹ค.

 

์œ„ ๋„ค ๊ฐ€์ง€๋Š” ๋ฐ˜๋“œ์‹œ ์ง€ํ‚ค๋˜, ๊ณต์‹ ๋ฌธ์„œ์— ์ œ์‹œ๋œ ์ž๋ฐ” ์ฝ”๋“œ ์ปจ๋ฒค์…˜ ๋˜ํ•œ ์ง€ํ‚ค๋Š” ๊ฒƒ์„ ๋ชฉํ‘œ๋กœ ํ–ˆ๋‹ค. 

Day 1

ํ”„๋ฆฌ์ฝ”์Šค๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ ์ „, ์ž๋ฐ” ์ฝ”๋“œ ์ปจ๋ฒค์…˜๊ณผ ์ปค๋ฐ‹ ์ปจ๋ฒค์…˜์„ ์ˆ™์ง€ํ•˜๊ณ  ๊ฐ์ฒด์ง€ํ–ฅ ์ƒํ™œ์ฒด์กฐ 9๊ฐ€์ง€ ์›์น™๋“ค์„ ์ˆ™์ง€ํ•˜๋Š” ์ •๋„๊นŒ์ง€๋งŒ ํ•ด๋‘์—ˆ๊ณ , ์ž๊ธฐ์†Œ๊ฐœ์„œ ์ž‘์„ฑ์ด ์ƒ๊ฐ๋ณด๋‹ค ๊ธธ์–ด์ง„ ํƒ“์— ์ง€๋‚œ 5๊ธฐ์˜ ํ”„๋ฆฌ์ฝ”์Šค ๋ฌธ์ œ๋“ค์„ ์‚ดํŽด๋งŒ ๋ณด๊ณ  ํ’€์–ด๋ณด์ง€๋Š” ๋ชปํ•œ ์ƒํƒœ์˜€๋‹ค.

 

๊ทธ๋ž˜์„œ ๋ฏธ์…˜์„ ์ฒ˜์Œ ํ™•์ธํ•  ๋•Œ ๋™์ผํ•œ ์ˆซ์ž์•ผ๊ตฌ ๋ฏธ์…˜์ธ ๊ฒƒ์„ ํ™•์ธํ•˜๊ณ , ๋ฏธ๋ฆฌ ํ•œ ๋ฒˆ ํ’€์–ด๋ณผ๊ฑธ ํ•˜๋Š” ํ›„ํšŒ๋„ ์žˆ์—ˆ์ง€๋งŒ, ์–ด์ฐŒ๋ณด๋ฉด  ์ด์ „ ๊ธฐ์ˆ˜ ๋ถ„๋“ค์ด ์ด ๋ฌธ์ œ๋ฅผ ์–ด๋–ป๊ฒŒ ํ’€์—ˆ๋Š”์ง€ ์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด์ง€ ์•Š์€ ๊ฒƒ์€ ๋‹คํ–‰์ด์—ˆ๋‹ค. 

 

1. JDK 17 ์„ธํŒ…

๋ณธ๋ก ์œผ๋กœ ๋“ค์–ด๊ฐ€ ๋ฏธ์…˜์„ ๋ฐ›๊ณ  ์š”๊ตฌ์‚ฌํ•ญ๋“ค์„ ํ•œ ๋ฒˆ ์ญ‰ ์ฝ๋‹ค๊ฐ€, 'JDK 17 ๋ฒ„์ „์—์„œ ์‹คํ–‰ ๊ฐ€๋Šฅํ•ด์•ผ ํ•œ๋‹ค.'๋Š” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ์„ ๋ฐœ๊ฒฌํ–ˆ๋‹ค. ์ด ์ „๊นŒ์ง€ ์ญ‰ 11 Version์„ ์‚ฌ์šฉํ•ด์™”์–ด์„œ ๋ฒ„์ „์„ ๋ฐ”๊พธ๋Š” ๋ฐฉ๋ฒ•์„ ์ฐพ๊ณ  ๋ฐ”๊พธ๋Š” ๋ฐ๊นŒ์ง€ ๋Œ€๋žต 3-40๋ถ„์ •๋„ ์†Œ์š”ํ•œ ๊ฒƒ ๊ฐ™๋‹ค.

 

๋ฒ„์ „ ๋ณ€๊ฒฝ์—๋Š” ์•„๋ž˜ ์ž๋ฃŒ๊ฐ€ ๋„์›€์ด ๋งŽ์ด ๋˜์—ˆ๋‹ค.

 

[Java] MacOS ํ™˜๊ฒฝ์—์„œ Java JDK ์„ค์ • ๋ฐ ๋ณ€๊ฒฝํ•˜๊ธฐ : homebrew, ๋‹ค์šด๋กœ๋“œ ํŒŒ์ผ

ํ•ด๋‹น ํ™˜๊ฒฝ์—์„œ๋Š” MacOS ํ™˜๊ฒฝ์—์„œ Java JDK๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค. ํ•ด๋‹น ๊ธ€์—์„œ๋Š” Java JDK 11 ๋ฒ„์ „์—์„œ Java JDK 17 ๋ฒ„์ „์œผ๋กœ ์˜ฌ๋ฆฌ๋Š” ์ž‘์—… ์œ„์ฃผ๋กœ ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค. 1) ์ž๋ฐ” JDK ๋ฒ„์ „ ํ™•์ธ ๐Ÿ’ก

adjh54.tistory.com

 

2. ๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ ์ •๋ฆฌ

JDK 17์„ ์„ธํŒ…ํ•˜๊ณ , ๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ๋“ค์„ ์ •๋ฆฌํ•˜๋‹ˆ ๋Œ€๋žต ์–ด๋–ค ํด๋ž˜์Šค์— ์–ด๋–ค ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•ด์•ผ ํ•  ์ง€ ์–ด๋ ดํ’‹์ด ๊ฐ์€ ์žก์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค. ํด๋ž˜์Šค ๋„ค์ด๋ฐ์„ ํ•˜๊ณ  ํด๋ž˜์Šค์— ์–ด๋–ค ๊ธฐ๋Šฅ์„ ๋„ฃ์„์ง€ ๊ฐ€๋ณ๊ฒŒ ๋ฉ”๋ชจ๋ฅผ ํ•˜์˜€๊ณ , ์ด์ œ๋ถ€ํ„ฐ๋Š” ์–ด๋–ค ์ˆœ์„œ, ์–ด๋–ค ๊ตฌ์กฐ๋กœ ๋งŒ๋“ค์–ด ๋‚˜๊ฐ€์•ผ ํ•  ์ง€ ๊ณ ๋ฏผ์ด์—ˆ๋‹ค.

 

 

3. ์„ค๊ณ„๋ฅผ ์–ด๋–ป๊ฒŒ ํ• ์ง€

๊ตฌํ˜„์„ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ์ง€ ๋ง‰๋ง‰ํ–ˆ๋‹ค. ์†์ด ๊ฐ€๋Š”๋Œ€๋กœ ๊ตฌํ˜„ํ•ด๋ณผ๊นŒ๋ผ๋Š” ์ƒ๊ฐ๋„ ํ–ˆ์ง€๋งŒ, ์„ค๊ณ„๋ฅผ ์ดˆ๊ธฐ์— ์ž˜ ํ•ด๋‘์–ด์•ผ ๋‚˜์ค‘์— ๊ณ ์ƒ์„ ๋œ ํ•  ๊ฒƒ ๊ฐ™์•˜๊ธฐ์— ํƒœ๋ธ”๋ฆฟ์œผ๋กœ ์—ฌ๋Ÿฌ ๋ฒˆ ๊ตฌ์กฐ๋ฅผ ๊ทธ๋ ธ๋‹ค๊ฐ€ ์ง€์› ๋‹ค๊ฐ€ ๋ฐ˜๋ณตํ•˜๋ฉฐ ์ดˆ์•ˆ์„ ์–ด๋–ป๊ฒŒ ๊ทธ๋ ค๋‚˜๊ฐˆ์ง€์— ์ง‘์ค‘ํ–ˆ๋‹ค.

 

์š”๋Ÿฐ์‹์œผ๋กœ 

 

4. MVC ํŒจํ„ด์— ์ž…๊ฐํ•ด์„œ ์งœ๋ณด์ž.

  • ๋„๋ฉ”์ธ - ๋„๋ฉ”์ธ ๊ตฌ์กฐ

์ฒ˜์Œ์—๋Š” MVC ํŒจํ„ด์ด ์•„๋‹Œ 'Computer'์™€ 'Player'๋ผ๋Š” ๋‘ ๊ฐ€์ง€ ๋„๋ฉ”์ธ์„ ๋งŒ๋“ค๊ณ  ์ด๋Ÿฐ ํ๋ฆ„๋Œ€๋กœ ํ•ด๋ณด๋ ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

  1. main์—์„œ Computer๋ฅผ ํ˜ธ์ถœ
  2. Computer์—์„œ Player์—๊ฒŒ Input ์š”์ฒญ
  3. Player์—์„œ ์ž…๋ ฅ๊ณผ ๋™์‹œ์— Input ๊ฐ’์„ ๊ฒ€์ฆํ•œ ํ›„ Computer์—๊ฒŒ ๊ฐ’์„ ์ „๋‹ฌ
  4. Computer์—์„œ ์ „๋‹ฌ ๋ฐ›์€ ๊ฐ’์„ ํ†ตํ•ด Score๋ฅผ ๊ณ„์‚ฐํ•ด์„œ Player์—๊ฒŒ ์ „๋‹ฌ..

์ด๋ ‡๊ฒŒ ๋‘ ๋„๋ฉ”์ธ์ด ์„œ๋กœ ๋ฌธ๋‹ตํ•˜๋Š” ๋ฐฉ์‹์„ ์ƒ๊ฐํ–ˆ์—ˆ๋‹ค. ๋ฌธ์ œ๋Š” ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ณผ๋ฅจ์ด ์ปค์งˆ์ˆ˜๋ก, ๋„๋ฉ”์ธ ์ฝ”๋“œ๊ฐ€ ๋„ˆ๋ฌด ๊ธธ์–ด์ง€๊ธฐ ๋•Œ๋ฌธ์— ํด๋ž˜์Šค๋ฅผ ๋ถ„๋ฆฌํ•ด์•ผ ํ•˜๊ณ  ๊ทธ๋ ‡๊ฒŒ ๋˜๋ฉด ๊ตฌ์กฐ๊ฐ€ ์ง๊ด€์ ์œผ๋กœ ๋ณด์ด์ง€ ์•Š์„ ์šฐ๋ ค๊ฐ€ ์žˆ์–ด ์ด ๋ฐฉ์‹์„ ์ฑ„ํƒํ•˜์ง€ ์•Š์•˜๋‹ค.

์ฐพ์•„๋ณด๋‹ˆ ์ด์™€ ๊ฐ™์€ ์„ค๊ณ„ ๋ฐฉ์‹์„ ๋„๋ฉ”์ธ ์ฃผ๋„ ์„ค๊ณ„(Domain Driven Design)๋ฐฉ์‹์ด๋ผ๊ณ  ํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.
  • MVC ํŒจํ„ด

MVC ํŒจํ„ด

MVC ํŒจํ„ด์„ ์ƒ๊ฐํ•˜๋‹ˆ Controller์— ์–ด๋–ค ๊ฑธ ๋งŒ๋“ค๊ณ , View์— ์–ด๋–ค ๊ฑธ ๋งŒ๋“ค๊ณ , Model์— ์–ด๋–ค ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ด์„ ์ง€ ๋“ฑ๋“ฑ ์ข…ํ•ฉํ•˜์—ฌ ๋Œ€๋žต ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„์„ ํ•ด์•ผํ•  ์ง€ ๋ณด์ด๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค.

 

5. ๊ฐœ์ธ ์—ฐ์Šต์šฉ ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ

์•„์ง ๊ธฐ๋Šฅ๋งˆ๋‹ค ์ปค๋ฐ‹ํ•˜๋Š”๋ฐ ์ต์ˆ™์น˜ ์•Š์•˜๊ณ , ์–ธ์ œ๋“ ์ง€ ๊ตฌ์กฐ๊ฐ€ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์—ˆ๊ธฐ์— ์šฐ์„  ์—ฐ์Šต์„ ํ•ด๋ณด๊ณ ์ž ์—ฐ์Šต์šฉ ๋ธŒ๋žœ์น˜๋ฅผ ํ•˜๋‚˜ ์ƒ์„ฑํ•˜๊ณ  ์ง„ํ–‰ํ–ˆ๋‹ค.

 

์šฐ์„  ์š”๊ตฌ์‚ฌํ•ญ์— ๋Œ€ํ•ด ๊ตฌํ˜„ํ•ด์•ผ ํ•  ๊ธฐ๋Šฅ๋“ค์„ ํ•˜๋‚˜์”ฉ ๊ตฌํ˜„ํ•˜๊ณ  ์กฐ๋ฆฝํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์ง„ํ–‰ํ–ˆ๋‹ค. 

 

๋จผ์ € ๋‹ค์Œ ๋„ค ๊ฐ€์ง€ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค.

1) ์šฐ์„  ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ์— ์ž‘์„ฑ๋œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ๋‚œ์ˆ˜ 3๊ฐœ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํด๋ž˜์Šค ์ƒ์„ฑ (NumberGenerator)

2) ์ž…๋ ฅ๊ฐ’์— ๋Œ€ํ•œ ๊ฒ€์ฆ๊ธฐ ํด๋ž˜์Šค ์ƒ์„ฑ (InputValidator)

3) ์ž…๋ ฅ๊ฐ’์„ ์Šค์ฝ”์–ด๋กœ ์ธก์ •ํ•˜๊ธฐ ์ „ ์ปฌ๋ ‰์…˜์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ์ปจ๋ฒ„ํ„ฐ ํด๋ž˜์Šค ์ƒ์„ฑ (StringToListConvertor)

4) ์ž…๋ ฅ๊ฐ’์— ๋Œ€ํ•œ ์Šค์ฝ”์–ด๋ฅผ ์ธก์ • (ex. 1๋ณผ 1์ŠคํŠธ๋ผ์ดํฌ, 3์ŠคํŠธ๋ผ์ดํฌ, ๋‚ซ์‹ฑ) ํ•˜๋Š” ํด๋ž˜์Šค์™€ ๋ฉ”์†Œ๋“œ ์ƒ์„ฑ (ScoreCalculator)

 

 

์ด ํ›„ Domain ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค๊ณ  ํŒจํ‚ค์ง€ ๋‚ด๋ถ€์— Baseball, Computer, Player์„ ๋งŒ๋“ค๊ณ , Baseball ๋„๋ฉ”์ธ์—์„œ ์ธ์Šคํ„ด์Šค ๋ฉค๋ฒ„๋ฅผ Computer, Player๋กœ ์„ค์ •ํ•˜์˜€๋Š”๋ฐ ์ด๋ ‡๊ฒŒ ํ•˜๋‹ˆ ๋„๋ฉ”์ธ์ด ๋„๋ฉ”์ธ์„ ์˜์กดํ•˜์—ฌ ์–ด์ƒ‰ํ•œ ๋Š๋‚Œ์„ ์ฃผ์—ˆ๋‹ค.

 

๊ทธ๋ž˜์„œ ๊ฒฐ๊ตญ ๊ตฌ์กฐ๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ƒˆ๋กœ ์ •๋ฆฝํ–ˆ๋‹ค.

main์—์„œ Controller๋ฅผ ํ†ตํ•ด ๊ฒŒ์ž„์„ ์‹คํ–‰ -> Controller์—์„œ Service๋ฅผ ํ†ตํ•ด ๋‚œ์ˆ˜ ์ƒ์„ฑ -> View๋ฅผ ํ†ตํ•ด ์ž…๋ ฅ๊ณผ ๋™์‹œ์— ๊ฒ€์ฆ -> Controller์—์„œ Service๋ฅผ ํ†ตํ•ด ์Šค์ฝ”์–ด ๊ณ„์‚ฐ -> View๋ฅผ ํ†ตํ•ด ์ถœ๋ ฅ  

6. ๊ตฌํ˜„

๊ตฌํ˜„ ์ž์ฒด๋งŒ ๋ณด๋ฉด ๊ทธ๋ฆฌ ์˜ค๋ž˜ ๊ฑธ๋ฆฌ์ง€ ์•Š์•˜๋‹ค.

๋‹ค๋งŒ ์ปจ๋ฒค์…˜์— ์–ด๊ธ‹๋‚˜๋Š” ์•„์ง ๊ณ ์น˜์ง€ ๋ชปํ•œ ์Šต๊ด€๋“ค์ด ์ฝ”๋“œ์— ๋“œ๋ฌธ๋“œ๋ฌธ ์กฐ๊ธˆ์”ฉ ๋‚จ์•„ ์žˆ์—ˆ๋‹ค. 

 

 ์ œ์ผ ํฐ ๋ฌธ์ œ๋Š” Controller์˜ start() ๋ฉ”์†Œ๋“œ ๋‚ด๋ถ€ while๋ฌธ ์•ˆ์— if๋ฌธ, if๋ฌธ์•ˆ์— ๋˜ if๋ฌธ์ด ๋“ค์–ด๊ฐ€ indent๊ฐ€ 3์ด ๋˜์–ด, ์ด๋กœ ์ธํ•ด ๊ฐ€๋…์„ฑ์ด ๋‚˜๋น ์ง€๊ณ , ๋ฉ”์†Œ๋“œ์˜ ์‘์ง‘๋„๊ฐ€ ์˜ฌ๋ผ๊ฐ”๋˜ ๊ฒƒ. -> ๊ตฌ์กฐ๋ฅผ ๋ฐ”๊พธ๋ฉด ๊ณ ์น  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.

 

2023.10.16 - [๐Ÿ“• Spring/Java] - [Java] ๊ฐ์ฒด์ง€ํ–ฅ ์ƒํ™œ์ฒด์กฐ ์›์น™ 9๊ฐ€์ง€์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž - indent ๋Š” 2 ์ด์ƒ์„ ๋„˜์–ด๊ฐ€์ง€ ์•Š๋„๋ก ํ•˜์ž.

 


Day 2

์ฝ”๋“œ๋ฅผ ๋ฆฌํŽ™ํ† ๋งํ•˜๊ณ , ๊ตฌ์กฐ ๋ณ€๊ฒฝ์ ์— ๋Œ€ํ•ด ์ƒ๊ฐํ•ด๋ณด์•˜๋‹ค.

1. ๋ฆฌํŽ™ํ† ๋ง

1. rename : (Output) ์ƒ์ˆ˜ PASS -> SUCCESS ๋ณ€๊ฒฝ

// private static final String PASS = "3๊ฐœ์˜ ์ˆซ์ž๋ฅผ ๋ชจ๋‘ ๋งžํžˆ์…จ์Šต๋‹ˆ๋‹ค! ๊ฒŒ์ž„ ์ข…๋ฃŒ";
 private static final String SUCCESS = "3๊ฐœ์˜ ์ˆซ์ž๋ฅผ ๋ชจ๋‘ ๋งžํžˆ์…จ์Šต๋‹ˆ๋‹ค! ๊ฒŒ์ž„ ์ข…๋ฃŒ";

๊ฒŒ์ž„์—์„œ ์ด๊ฒผ์„ ๋•Œ ์ถœ๋ ฅํ•  ๋ฉ”์‹œ์ง€์˜ ์ƒ์ˆ˜ ์ด๋ฆ„์„ PASS๋ผ๊ณ  ๋„ค์ด๋ฐ ํ–ˆ์—ˆ๋Š”๋ฐ, PASS ๋ณด๋‹ค๋Š” SUCCESS๋‚˜ WIN์ด ๋” ์ง๊ด€์ ์ธ ๋„ค์ด๋ฐ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ด ๋ณ€๊ฒฝํ–ˆ๋‹ค.

 

2. ref : (BaseballGameController) ์ง€์—ญ ๋ณ€์ˆ˜ answer ํ•„๋“œ -> ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋กœ ๋ณ€๊ฒฝ 

  • '์ง€์—ญ๋ณ€์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๋Š๋ƒ, ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋กœ ์‚ฌ์šฉํ•˜๋Š๋ƒ'์— ๋Œ€ํ•œ ๊ณ ๋ฏผ์ด ์žˆ์—ˆ๋‹ค.
  • ์•„์ง ๋ช…๋ฐฑํ•œ ๋‹ต์€ ์ฐพ์ง€ ๋ชปํ–ˆ์ง€๋งŒ ๊ฐ ํŠน์ง•์€ ์ƒ๊ฐํ•ด ๋ณผ ์ˆ˜ ์žˆ์—ˆ๋‹ค.
    • ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋กœ ์‚ฌ์šฉํ•  ๋•Œ : ์ผ๋ฐ˜์ ์œผ๋กœ ๊ฐ์ฒด์˜ ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•˜๊ณ  ๊ณต์œ ํ•ด์•ผ ํ•  ๋•Œ๋Š” ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋ฅผ ์‚ฌ์šฉ.
    • ์ง€์—ญ ๋ณ€์ˆ˜ : ๋ฉ”์†Œ๋“œ๊ฐ€ ์ข…๋ฃŒ๋˜๋ฉด GC์— ์˜ํ•ด ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ํ•ด์ œ๋œ๋‹ค.
  • ์ž‘์„ฑํ•˜๋ฉด์„œ ๊นจ๋‹ฌ์€๊ฑด๋ฐ, ์—ฌ๊ธฐ์„œ๋Š” ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค, ์ง€์—ญ ๋ณ€์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ๋งž๋Š” ๊ฒƒ ๊ฐ™๋‹ค. ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋กœ ์‚ฌ์šฉํ•˜๋ฉด ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ํ™˜๊ฒฝ์—์„œ์˜ ํ•„๋“œ๊ฐ€ ๊ณต์œ ๋  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์„ ๊ฐ„๊ณผํ–ˆ๋‹ค.
    • ์ด๋ ‡๊ฒŒ ์ˆ˜์ •ํ–ˆ๋˜ ์ด์œ ๋Š” ํ•„๋“œ๋ฅผ ์ธ์Šคํ„ด์Šค ํ•„๋“œ๋กœ ํ†ต์ผํ•˜์—ฌ ๊ฐ€๋…์„ฑ์„ ๋†’์ด๋ ค๋Š” ์˜๋„์˜€๋Š”๋ฐ, ์ถ”ํ›„ ์ง€์—ญ๋ณ€์ˆ˜๋กœ ๋‹ค์‹œ ๋ณ€๊ฒฝํ•ด์•ผ๊ฒ ๋‹ค. (answer ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ result ๋˜ํ•œ)

 

3. ref : (BaseballGameController) indent depth ๊ฐ€ 3 ์ธ ๋ฉ”์†Œ๋“œ ๋ถ„๋ฆฌ

์ˆ˜์ • ์ „

    public void start() {
        output.printStartMessage();
        List<Integer> answer = randomNumberGenerateService.getGeneratedNumbers();

        while (true) {
            output.printInputRequestMessage();
            result = scoreService.calculateScore(input.getInput(), answer);
            output.printResult(result);
            if (isAllStrike(result)) {
                output.printRestartOrExitMessage();
                if (input.getExit() == 1) {
                    answer = randomNumberGenerateService.getGeneratedNumbers();
                    continue;
                }
                break;
            }
        }
    }

 
์ˆ˜์ • ํ›„

public void start() {
    output.printStartMessage();
    while (true) {
        answer = makeNewAnswer();
        playOneRound(answer);
        if (input.getRestartOrExit() == EXIT) {
            break;
        }
    }
}

private void playOneRound(List<Integer> answer) {
    while (true) {
        output.printInputRequestMessage();
        result = scoreService.calculateScore(input.getSubmit(), answer);
        output.printResult(result);
        if (scoreService.isAllStrike(result)) {
            output.printRestartOrExitMessage();
            break;
        }
    }
}
  • indent ๊ฐ€ ์ปค์ง€๋ฉด์„œ ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ง€๊ณ , ์‘์ง‘๋„๊ฐ€ ๋†’์•„์ ธ ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ์–ด๋ ค์›Œ ์งˆ ์šฐ๋ ค๊ฐ€ ์žˆ์—ˆ๋‹ค.
    • ๋‹น์žฅ์€ ๋ฉ”์†Œ๋“œ๋ฅผ ๋ถ„๋ฆฌํ•˜๋ฉด์„œ depth๋ฅผ 2๋กœ ๋ฐ”๊พธ์—ˆ์ง€๋งŒ while๋ฌธ ๋‚ด๋ถ€์˜ if๋ฌธ๋„ ๋ฉ”์†Œ๋“œ๋กœ ๋นผ๋Š” ๋ฐฉ์•ˆ๋„ ์ƒ๊ฐํ•ด๋ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.

4. InputValidator

InputValidator ํด๋ž˜์Šค์—์„œ ๋ณ€๊ฒฝ์ ์ด ์ข€ ์žˆ์—ˆ๋‹ค.
 
1. ์šฐ์„  ๋ฉ”์†Œ๋“œ ์ด๋ฆ„์„ ์ˆซ์ž๊ฐ€ ์•„๋‹Œ ๋ฌธ์ž์—ด๋กœ ๋ณ€๊ฒฝํ•˜์˜€๋‹ค.

//    public static boolean isBetween1And9(String input) {
    public static boolean isBetweenOneAndNine(String input) {
        if (input.chars().anyMatch(c -> c < '1' || c > '9')) {
            throw new IllegalArgumentException("์ž…๋ ฅ๊ฐ’์ด 1~9 ์‚ฌ์ด์˜ ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.");
        }
//    public static boolean isEqualTo1or2(String line) {
//        return line.charAt(0) == '1' || line.charAt(0) == '2';
    public static boolean isEqualToOneOrTwo(String line) {
        if (line.charAt(0) != '1' || line.charAt(0) != '2') {
            throw new IllegalArgumentException("1 ๋˜๋Š” 2๋งŒ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
        }
        return true;
    }

 
2. InputValidator ํด๋ž˜์Šค์—์„œ๋Š” Player๋กœ๋ถ€ํ„ฐ ๋‘ ์ข…๋ฅ˜์˜ ์ž…๋ ฅ์„ ๋ฐ›๋Š”๋‹ค.

  • ์ฒซ ๋ฒˆ์งธ๋Š” ์ˆซ์ž ์•ผ๊ตฌ ๊ฒŒ์ž„์— ๋Œ€ํ•œ ๋‹ต์„ ์ œ์•ˆํ•˜๋Š” ๊ฐ’
  • ๋‘ ๋ฒˆ์งธ๋Š” ์žฌ์‹œ์ž‘/์ข…๋ฃŒ์— ๋Œ€ํ•œ ๊ฐ’ ์ด๋ ‡๊ฒŒ ๋‘ ๊ฐ€์ง€์˜ ์ž…๋ ฅ๊ฐ’.

์ด ๋‘ ๊ฐ€์ง€์˜ ์ž…๋ ฅ๊ฐ’์„ ๊ฒ€์ฆํ•˜๋Š” ๋กœ์ง๋“ค์ด ํ†ต์ผ์ด ๋˜์–ด์žˆ์ง€ ์•Š์•„ ํ•œ ๋กœ์ง์œผ๋กœ ํ†ต์ผํ•˜์˜€๋‹ค.

  • ํ†ต์ผํ•œ ๋กœ์ง : if๋ฌธ์—์„œ ์˜ˆ์™ธ์กฐ๊ฑด์„ ๊ฒ€์‚ฌํ•˜๊ณ  ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ์ผ€์ด์Šค๋ฉด IllegalArgumentException์„ ๋˜์ง€๊ณ , ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์œผ๋ฉด true๋ฅผ ๋ฆฌํ„ดํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ†ต์ผ

 

Before 

public static boolean isEqualTo1or2(String line) {
        return line.charAt(0) == '1' || line.charAt(0) == '2';
    }

 
After

public static boolean isEqualToOneOrTwo(String line) {
    if (line.charAt(0) != '1' && line.charAt(0) != '2') {
        throw new IllegalArgumentException("1 ๋˜๋Š” 2๋งŒ ์ž…๋ ฅ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.");
    }
    return true;
}

 
 
 3. void validateXXX -> boolean isXXX

  • ๊ธฐ์กด : validateXXX ๋ฉ”์†Œ๋“œ๋ฅผ Input ํด๋ž˜์Šค์—์„œ ์ž…๋ ฅ์— ๋Œ€ํ•œ ๊ฒ€์ฆ์„ ํ•  ๋•Œ validateXXX(line)๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๊ฒ€์ฆ
  • ๋ณ€๊ฒฝ : ์ง๊ด€์ ์œผ๋กœ ์™€๋‹ฟ์ง€ ์•Š์„ ์šฐ๋ ค๊ฐ€ ์žˆ์–ด boolean์œผ๋กœ ๋ณ€๊ฒฝํ•˜๊ณ  if(isXXX(line))์œผ๋กœ ๋ณ€๊ฒฝํ•˜์˜€๋‹ค.

 
Before

public static boolean validateInput(String input) {
    if (isThreeChar(input) && isNumber(input) && isBetween1And9(input) && isNotDuplicate(input)) {
        return true;
    }
    return false;
}

public static void validateExit(String line) {
    if (!isLengthOne(line)) {
        throw new IllegalArgumentException("1 ๋˜๋Š” 2๋งŒ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
    }
    if (!isEqualTo1or2(line)) {
        throw new IllegalArgumentException("1 ๋˜๋Š” 2๋งŒ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
    }
}

 
After

public static boolean isSubmitValid(String input) {
    if (isThreeChar(input) && isNumber(input) && isBetweenOneAndNine(input) && isNotDuplicate(input)) {
        return true;
    }
    return false;
}

public static boolean isRestartOrExitValid(String input) {
    if (isLengthOne(input) && isEqualToOneOrTwo(input)) {
        return true;
    }
    return false;
}

 

5. ํŒจํ‚ค์ง€ ๊ตฌ์กฐ ๋ณ€๊ฒฝ

Before / After

  • util์˜ validator๋ฅผ exception ํŒจํ‚ค์ง€๋กœ ๋นผ๊ณ , converter๋ฅผ ์ƒ์œ„ ํŒจํ‚ค์ง€๋กœ ์˜ฌ๋ ธ๋‹ค.
    • ๊ทผ๊ฑฐ : util ํŒจํ‚ค์ง€๋ผ๊ณ  ์ด๋ฆ„ ์ง“๊ธฐ์— ์ง๊ด€์ ์ด์ง€ ์•Š๊ณ , validator๋Š” ๋”ฐ์ง€๊ณ  ๋ณด๋ฉด ์˜ˆ์™ธ๋ฅผ ๊ฒ€์ฆํ•˜๋Š” ํŒจํ‚ค์ง€๊ธฐ ๋•Œ๋ฌธ์— exception ํŒจํ‚ค์ง€๋กœ ๋นผ๋Š” ๊ฒƒ์ด ๋” ๊ฐ€๋…์„ฑ์ด ์ข‹๋‹ค๊ณ  ํŒ๋‹จ 

2. ๊ตฌ์กฐ ๋ณ€๊ฒฝ

ํ˜„์žฌ ๊ตฌ์กฐ๋ฅผ ์‚ดํŽด๋ณด๋ฉด
Model์—๋Š” Result ๋ฟ์ด๊ณ , Domain์ด ํ•˜๋‚˜๋„ ์—†๋‹ค. Model์—๋Š” View์— ๋‹ด์„ ๋ฐ์ดํ„ฐ๋งŒ ๋‹ด์œผ๋ฉด ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ Result ํด๋ž˜์Šค ํ•˜๋‚˜๋งŒ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ, ์ƒํƒœ๋ฅผ ์ €์žฅํ•˜๋Š” ๊ฐ์ฒด๋„ ๋ชจ๋ธ์ด ๋  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ๊ฐ„๊ณผํ•˜๊ณ  ์žˆ์—ˆ๋‹ค.

 

Domain์— Player์™€ Computer๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ด ๋‘ ๊ฐ์ฒด๋ฅผ ํ˜„์žฌ ์ƒํƒœ๋ฅผ ๋‹ด๋Š” ๋ชจ๋ธ๋กœ ์‚ฌ์šฉํ•ด์„œ Controller์—์„œ ์ด ๋‘ ๋ชจ๋ธ๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ ๋ฐ›๋„๋ก ์„ค๊ณ„ํ•˜๋Š” ๊ฒƒ๋„ ์ข‹์€ ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜์ธ ๊ฒƒ ๊ฐ™๋‹ค.

 

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ๋กœ์ง๊ณผ ์ •๋‹ต์„ ์ƒ์„ฑํ•˜๋Š” ๋กœ์ง์„ Computer์— ๋‹ด๊ณ  Service ๊ณ„์ธต ์ž์ฒด๋ฅผ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค. ์šฐ์„  ๋‚ด์ผ ๋„๋ฉ”์ธ์€ ๋งŒ๋“ค์–ด ์„œ๋น„์Šค ๋กœ์ง์„ ๋‘์–ด ๋„๋ฉ”์ธ์—์„œ ์„œ๋น„์Šค์˜ ์—ญํ• ์„ ํ•˜๋„๋ก ํ•  ์ง€, ์•„๋‹ˆ๋ฉด Computer, Player ๋„๋ฉ”์ธ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ๊ธฐ์กด ๋ฐฉ์‹๋Œ€๋กœ ๊ฐˆ ์ง€ ๊ณ ๋ฏผํ•ด๋ณด์•„์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.


10/21 - Day 3

1. ๋ฆฌํŽ™ํ† ๋ง

์–ด์ œ ์•„์ด๋””์–ด๋ฅผ ํ† ๋Œ€๋กœ ๊ตฌ์กฐ๋ฅผ ๋ฐ”๊ฟ”์„œ ํ•œ ๋ฒˆ ์ง„ํ–‰ํ•ด๋ณด์•˜๋‹ค.

Before / After

  • ๊ตฌ์กฐ๊ฐ€ ๋ฐ”๋€Œ๋ฉด์„œ ์„œ๋น„์Šค ๊ณ„์ธต์„ ์—†์•จ ์ˆ˜ ์žˆ์—ˆ๋‹ค. MVC ํŒจํ„ด์ด๋ผ ํ•จ์€ ์Šคํ”„๋ง์—์„œ๋Š” Controller ๊ณ„์ธต์ด Service ๊ณ„์ธต์„ ํ†ตํ•ด ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ์‹คํ–‰ํ•˜์ง€๋งŒ, ์ง€๊ธˆ ํ•˜๋Š” ๋ฏธ์…˜์€ ์ˆœ์ˆ˜ ์ž๋ฐ”๋กœ ํด๋ฆฌ์–ดํ•ด์•ผํ•˜๋Š” ๋ฏธ์…˜์ด๋‹ˆ Service ๊ณ„์ธต์„ ๋‘๋Š” ๊ฒƒ ๋ณด๋‹ค Model-Controller-View  3 Layer๋กœ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด ๋งž๋Š” ๊ฒƒ ๊ฐ™๋‹ค.

 

1. ์ƒˆ๋กœ ์ƒ์„ฑํ•œ Model : Computer.class

public class Computer {
    private static final Integer BALL_SIZE = 3;
    private final static Integer FIRST_NUMBER = 1;
    private final static Integer LAST_NUMBER = 9;

    public List<Integer> getGeneratedNumbers() {
        List<Integer> answer = new ArrayList<>();
        while (answer.size() < BALL_SIZE) {
            int randomNumber = Randoms.pickNumberInRange(FIRST_NUMBER, LAST_NUMBER);
            addIfNotInList(answer, randomNumber);
        }
        return answer;
    }

 

Computer ๋ชจ๋ธ์—์„œ ๋‚œ์ˆ˜ 3๊ฐœ(์ •๋‹ต)๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฉ”์†Œ๋“œ, ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ๋‘์—ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜์—ฌ Service ๊ณ„์ธต์„ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ๋‘ ๊ธฐ๋Šฅ์„ ํ•œ ํด๋ž˜์Šค์— ๋‹ด์œผ๋‹ˆ ์ฝ”๋“œ๊ฐ€ ๊ธธ์–ด์งˆ ์ˆ˜ ๋ฐ–์— ์—†์—ˆ๋‹ค. ์ถ”ํ›„ ์ด ๋‘ ๋ฉ”์†Œ๋“œ๋ฅผ ํด๋ž˜์Šค๋ฅผ ๋ถ„๋ฆฌํ•˜์—ฌ ์งง๊ฒŒ ์ค„์—ฌ์•ผ๊ฒ ๋‹ค.

 

 

2. ์ƒˆ๋กœ ์ƒ์„ฑํ•œ Model : Player.class

public class Player {

    private List<Integer> numbers;
    private Integer restartOrExit;

    public void inputNumbers() {
        String input = Console.readLine();
        if (!isInputNumbersValid(input)) {
            throw new IllegalArgumentException();
        }
        this.numbers = StringToList(input);
    }

    public void inputRestartOrExit() {
        String input = Console.readLine();
        if (!isRestartOrExitValid(input)) {
            throw new IllegalArgumentException();
        }
        this.restartOrExit = Integer.parseInt(input);
    }

    public List<Integer> getNumbers() {
        return numbers;
    }

    public Integer getRestartOrExit() {
        return restartOrExit;
    }
}
  • Player๋Š” ๋‘ ๊ฐ€์ง€ ์ƒํƒœ(ํ•„๋“œ)๋ฅผ ๊ฐ€์ง„๋‹ค.
    • ์ฒซ์งธ, ์ˆซ์ž ์•ผ๊ตฌ ๊ฒŒ์ž„์˜ ๋‹ต์„ ์ œ์‹œํ•˜๋Š” ํ•„๋“œ
    • ๋‘˜์งธ, ์ˆซ์ž ์•ผ๊ตฌ ๊ฒŒ์ž„์—์„œ ์Šน๋ฆฌํ•˜์˜€์„ ๋•Œ, ์žฌ์‹œ์ž‘/์ข…๋ฃŒ ์—ฌ๋ถ€๋ฅผ ์ œ์‹œํ•˜๋Š” ํ•„๋“œ

inputXXX() ๋ฉ”์†Œ๋“œ๋กœ ํ˜„์žฌ ์ƒํƒœ๋ฅผ Console์„ ํ†ตํ•ด ์ž…๋ ฅ๋ฐ›์•„ ๊ฒ€์ฆ๊นŒ์ง€ ๋งˆ์นœ ํ›„ ์ €์žฅํ•˜๊ณ , getXXX()์„ ํ†ตํ•ด ํ˜„์žฌ ์ƒํƒœ๋ฅผ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.

+ ์ด๋ ‡๊ฒŒ ์ˆ˜์ •ํ•จ์œผ๋กœ์จ BaseballGameController์˜ start() ๋ฉ”์†Œ๋“œ์—์„œ indent depth๋ฅผ 1๋กœ ์ค„์ผ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

 

 

์ˆ˜์ • ์ „ BaseballGameController.start() 

public void start() {
    output.printStartMessage();
    while (true) {
        answer = makeNewAnswer();
        playOneRound(answer);
        if (input.getRestartOrExit() == EXIT) {
            break;
        }
    }
}

 

์ˆ˜์ • ํ›„  BaseballGameController.start() 

public void start() {
    printStartMessage();
    while (player.getRestartOrExit() != EXIT) {
        playOneRound(computer.getGeneratedNumbers());
        player.inputRestartOrExit();
    }
}

 

3. ๊ธฐ์กด์˜ Result(Model) ๋ณ€๊ฒฝ์  

1. Result ๋ณด๋‹ค Score ๋ผ๋Š” ์ด๋ฆ„์ด ๋” ์ง๊ด€์ ์ด์—ฌ์„œ ์ด๋ฆ„์„ ๋ฐ”๊พธ์—ˆ๋‹ค.

 

2. isAllStrike()๋ฅผ ScoreService์—์„œ ๊ฒ€์‚ฌํ–ˆ๋Š”๋ฐ ์„œ๋น„์Šค ๊ณ„์ธต์„ ์—†์• ๊ณ , ๊ฐ์ฒด ์ž์ฒด์—์„œ ๊ฒ€์ฆํ•˜๋„๋ก ๋ณ€๊ฒฝํ•˜์˜€๋‹ค.

  • ์ƒ๊ฐํ•ด๋ณด๋ฉด Score๋ฅผ ScoreService์—์„œ ๊ฒ€์‚ฌํ•˜๋Š” ๊ฒƒ ๋ณด๋‹ค, Score์—์„œ ๊ฒ€์ฆํ•˜๋Š” ๊ฒƒ์ด ๋” ๊ฐ์ฒด ์ง€ํ–ฅ์ ์ธ ์„ค๊ณ„๋ผ๊ณ  ๋ณผ ์ˆ˜ ์žˆ๋‹ค. (์„œ๋น„์Šค ๊ณ„์ธต์„ ์ง€์šฐ๋ฉด์„œ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์–ป์–ด๊ฑธ๋ฆฐ ๋Š๋‚Œ)
  • ๊ฐ์ฒด ์ง€ํ–ฅ์ ์ธ ์„ค๊ณ„ ๋ฐฉ์‹์„ ์ฒดํ™”ํ•˜๋Š” ์—ฐ์Šต์ด ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™๋‹ค.
public class Score {

    private static final Integer THREE_STRIKE = 3;

	...

    public boolean isAllStrike() {
        return getStrike() == THREE_STRIKE;
    }
}

 

4. InputView ์‚ญ์ œ .. ์ด๊ฒŒ ๋งž๋Š”๊ฑธ๊นŒ? ๊ณ ๋ฏผ์ด์ง€๋งŒ ์šฐ์„  ๋ฐ”๊พธ์–ด๋ณด์•˜๋‹ค.

View์—๋Š” '์‚ฌ์šฉ์ž๋งˆ๋‹ค ๋‹ค๋ฅด๊ฒŒ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•˜๋Š” ๋ฐ์ดํ„ฐ'๋ฅผ ๋‹ด์•„์•ผ ํ•œ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ๊ณตํ†ต์œผ๋กœ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋Š” ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ•ด์•ผ ํ• ๊นŒ? ์•„์ง ๊ณ ๋ฏผ์ด์ง€๋งŒ ๋ฐ”๊พธ์–ด๋ณด์•˜๋‹ค.

 

๊ธฐ์กด InputView์—์„œ ์‚ฌ์šฉ์ž์—๊ฒŒ ๊ณตํ†ต์œผ๋กœ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•˜๋Š” '์ž…๋ ฅ์— ๊ด€ํ•œ ์•ˆ๋‚ด ๋ฉ”์‹œ์ง€'๋ฅผ ๋‹ด์•˜๋‹ค. ํ•˜์ง€๋งŒ View์—๋Š” ์‚ฌ์šฉ์ž๋งˆ๋‹ค '๋‹ค๋ฅด๊ฒŒ' ๋ณด์—ฌ ์ฃผ์–ด์•ผํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ด์•„์•ผ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋‹ˆ, InputView์—์„œ ์ˆ˜ํ–‰ํ•˜๋Š” ์—ญํ• ์„ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์ด ๋งž๋Š” ๊ฒƒ ๊ฐ™๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ, ์ปจํŠธ๋กค๋Ÿฌ๋กœ ๋ฉ”์†Œ๋“œ๋ฅผ ์ด๋™ํ•˜๊ณ , InputView๋ฅผ ์‚ญ์ œํ–ˆ๋‹ค.

 

๊ฒŒ์ž„ ์‹œ์ž‘ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ ( BaseballGameController.class )

public void printStartMessage() {
    System.out.println(START_MSG);
}

์ˆซ์ž ์ž…๋ ฅ ์š”์ฒญ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ ( BaseballGameController.class )

public void printSuggestNumberMessage() {
    System.out.print(REQUEST_NUMBER_MSG);
}

์ข…๋ฃŒ ์—ฌ๋ถ€ ์ž…๋ ฅ ์š”์ฒญ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ ( BaseballGameController.class )

public void printRestartOrExitMessage() {
    System.out.print(REQUEST_RESTART_OR_EXIT_MSG);
}

 

 

2. ์ˆ˜์ •ํ•ด์•ผ ํ•  ์‚ฌํ•ญ๋“ค

1. BaseBallGameController์˜ playOneRound() ๋ฉ”์†Œ๋“œ์˜ indent depth๊ฐ€ 2 

private void playOneRound(List<Integer> answer) {
    while (true) {
        printSuggestNumberMessage();
        player.inputNumbers();
        Score score = computer.calculateScore(player.getNumbers(), answer);
        outputView.printResult(score);
        if (score.isAllStrike()) {
            printRestartOrExitMessage();
            break;
        }
    }
}
  • start() ๋ฉ”์†Œ๋“œ์˜ indent depth๋Š” 1๋กœ ์ค„์ผ ์ˆ˜ ์žˆ์—ˆ์ง€๋งŒ, ์•„์ง playOneRound()์˜ indent depth๋Š” 2๋กœ ์œ ์ง€๋˜๊ณ  ์žˆ๋‹ค. ์–ด๋–ป๊ฒŒ ๋ฐ”๊ฟ”์•ผ indent๋ฅผ 1๋กœ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์„ ์ง€ ์ƒ๊ฐํ•ด๋ณด์•„์•ผ ๊ฒ ์ง€๋งŒ, ํ˜„์žฌ๋กœ์„  ์ข‹์€ ์•„์ด๋””์–ด๊ฐ€ ๋– ์˜ค๋ฅด์ง€ ์•Š๋Š”๋‹ค. ๊ณ„์† ๊ณ ๋ฏผํ•ด๋ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค. 

2. OutputView์˜ printResult() ๋ฉ”์†Œ๋“œ์—์„œ score๋ฅผ ์ธ์ž๋กœ ๋ฐ›์•„ score๋ฅผ ์กฐ๊ฑด๋ถ„๊ธฐ๋กœ "๊ฒ€์‚ฌ" ํ•˜๊ณ  ์žˆ๋‹ค. 

public void printResult(Score score) {
    if (score.getBall() == 0 && score.getStrike() == 0) {
        System.out.println(NOTHING);
        return;
    } else if (score.getStrike() == 3) {
        System.out.println(THREE_STRIKE);
        System.out.println(SUCCESS);
        return;
    }
    System.out.println(score.getBall() + BALL + score.getStrike() + STRIKE);
}
  • printResult๋ผ๊ณ  ํ•˜๋ฉด result๋กœ๋ถ€ํ„ฐ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ›์•„์™€ '์ถœ๋ ฅ'์— ์ค‘์ ์„ ๋‘” ๋ฉ”์†Œ๋“œ์ธ๋ฐ, ์ด ๋ฉ”์†Œ๋“œ์—์„œ score๋ฅผ '๊ฒ€์‚ฌ'ํ•˜์—ฌ ์กฐ๊ฑด์— ๋”ฐ๋ผ ์ถœ๋ ฅ์„ ๋‹ฌ๋ฆฌํ•˜๊ณ  ์žˆ๋Š”๋ฐ, '์ถœ๋ ฅ'๊ณผ '๊ฒ€์ฆ'์˜ ๋ถ„๋ฆฌ๊ฐ€ ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™๋‹ค. ์ด ๋˜ํ•œ ์•„์ง ์ข‹์€ ์•„์ด๋””์–ด๊ฐ€ ๋– ์˜ค๋ฅด์ง€ ์•Š์•„ ๊ณ ๋ฏผํ•ด๋ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.

 

3. ์•„๊นŒ๋„ ์–ธ๊ธ‰ํ–ˆ์ง€๋งŒ, Computer๊ฐ€ ๋‘ ๊ฐ€์ง€ ๊ธฐ๋Šฅ์„ ๋‹ด๋‹นํ•˜๋ฉด์„œ ์ฝ”๋“œ๊ฐ€ ๊ธธ์–ด์ง€๊ณ  ์žˆ๋‹ค. ํด๋ž˜์Šค ๋ถ„๋ฆฌ๊ฐ€ ํ•„์š”.

public class Computer {
    private static final Integer BALL_SIZE = 3;
    private final static Integer FIRST_NUMBER = 1;
    private final static Integer LAST_NUMBER = 9;

    public List<Integer> getGeneratedNumbers() {
        List<Integer> answer = new ArrayList<>();
        while (answer.size() < BALL_SIZE) {
            int randomNumber = Randoms.pickNumberInRange(FIRST_NUMBER, LAST_NUMBER);
            addIfNotInList(answer, randomNumber);
        }
        return answer;
    }

    private void addIfNotInList(List<Integer> answer, int randomNumber) {
        if (!answer.contains(randomNumber)) {
            answer.add(randomNumber);
        }
    }

    public Score calculateScore(List<Integer> playerInput, List<Integer> answer) {
        Integer strike = calculateStrike(playerInput, answer);
        Integer ball = calculateBall(playerInput, answer);
        return new Score(strike, ball);
    }

    public Integer calculateStrike(List<Integer> playerInput, List<Integer> answer) {
        return (int) IntStream.range(0, answer.size())
                .filter(index -> playerInput.get(index)
                        .equals(answer.get(index)))
                .count();
    }

    public Integer calculateBall(List<Integer> playerInput, List<Integer> answer) {
        return (int) IntStream.range(0, answer.size())
                .filter(index -> excludeStrike(playerInput, answer, index) && includeBall(playerInput, answer, index))
                .count();
    }

    private boolean excludeStrike(List<Integer> playerInput, List<Integer> answer, int index) {
        return !playerInput.get(index).equals(answer.get(index));
    }

    private boolean includeBall(List<Integer> playerInput, List<Integer> answer, int index) {
        return playerInput.contains(answer.get(index));
    }
}
  • 50 line์ด ๋„˜์–ด๊ฐˆ ์ •๋„๋กœ ๋ผ์ธ์ด ๊ธธ์–ด์ง€๊ณ  ์žˆ๋Š”๋ฐ, ํด๋ž˜์Šค๋ฅผ ๋ถ„๋ฆฌํ•ด์„œ ์—”ํ‹ฐํ‹ฐ๋ฅผ ์ž‘๊ฒŒ ์œ ์ง€ํ•ด์•ผ ํ•  ์ง€ ๊ณ ๋ฏผ์ค‘์ด๋‹ค.

 

4. Player์˜ ํ•„๋“œ๋“ค์„ ํฌ์žฅํ•ด์•ผ ํ•  ์ง€ ๊ณ ๋ฏผ. 

  1. ’์ž…๋ ฅ‘์„ ๊ธฐ์ค€์œผ๋กœ ๋ณด๋ฉด ๊ณตํ†ต๋˜๋Š” ํ•„๋“œ์ธ ๋‘ ํ•„๋“œ๋ฅผ ํ•˜๋‚˜์˜ ํด๋ž˜์Šค๋กœ ๋ฌถ์€ ์ดํ›„, ๋ฌถ์€ ํด๋ž˜์Šค ๋‚ด๋ถ€์—์„œ ๊ฐ’์„ ๊ฒ€์ฆํ•˜๋„๋ก ํ•˜์—ฌ ์ƒ์œ„ ํด๋ž˜์Šค์— ๊ณผ๋„ํ•œ ์ฑ…์ž„์„ ์ฃผ๋Š” ๊ฒƒ์„ ๋ง‰์„ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.
public class Player {

    private List<Integer> numbers;
    private Integer restartOrExit;

 

+ ์‹œ๋„ํ•ด๋ณธ ๊ฒฐ๊ณผ, Player ๋„๋ฉ”์ธ์—์„œ ํ•„๋“œ์˜ ์ƒํƒœ์— ๋Œ€ํ•œ ๊ฒ€์‚ฌ๋ฅผ ํ•˜๋Š” '์ฑ…์ž„'์ด ๊ณผ์ค‘๋˜๋Š” ๊ฒƒ์„ ๋ง‰์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค. 

But ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ ธ ๋ณด์˜€๋‹ค..

Before

 

After


10/22 - Day 4

1.  ์ œ์ถœ์šฉ ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ

์–ด๋Š์ •๋„ ๊ฐ์„ ์žก์•˜์œผ๋‹ˆ ๋ณธ๊ฒฉ์ ์œผ๋กœ ์ œ์ถœ์šฉ ๋ธŒ๋žœ์น˜๋ฅผ ๋งŒ๋“ค๊ณ  ์ง„ํ–‰ํ–ˆ๋‹ค. 

2.  ๋ฆฌํŽ™ํ† ๋ง 

0. ์–ด์ œ ๋ž˜ํ•‘ํ•œ Input ํด๋ž˜์Šค๋ฅผ ๋ž˜ํ•‘์„ ํ’€๊ธฐ๋กœ ๊ฒฐ์ •.

๋‹ค์‹œ ์›๋ž˜๋Œ€๋กœ ..

๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ ธ ๋ณด์ด๋Š” ๊ฑด ๋‘˜์งธ์น˜๊ณ  ์ฝ”๋“œ์— ํ™•์‹ ์ด ์—†์–ด์„œ ์šฐ์„  ๋‹ค์‹œ ์›๋ž˜๋Œ€๋กœ ๋ฐ”๊พธ์—ˆ๋‹ค. 

1. Controller์—์„œ ์ˆ˜ํ–‰ํ•˜๋˜ ์ž…๋ ฅ ์š”๊ตฌ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ ๊ธฐ๋Šฅ์„ InputView ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑํ•ด์„œ ์—ญํ•  ์œ„์ž„

public class InputView {

    private static final String REQUEST_RESTART_OR_EXIT_MSG = "๊ฒŒ์ž„์„ ์ƒˆ๋กœ ์‹œ์ž‘ํ•˜๋ ค๋ฉด 1, ์ข…๋ฃŒํ•˜๋ ค๋ฉด 2๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.";
    private static final String REQUEST_NUMBER_MSG = "์ˆซ์ž๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š” : ";

    public void printSuggestNumberMessage() {
        System.out.print(REQUEST_NUMBER_MSG);
    }

    public void printRestartOrExitMessage() {
        System.out.println(REQUEST_RESTART_OR_EXIT_MSG);
    }
}

 

  • View๊ฐ€ ๋ชจ๋ธ๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์„ ๋•Œ, '์‚ฌ์šฉ์ž๋งˆ๋‹ค ๋‹ค๋ฅด๊ฒŒ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•˜๋Š” ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•ด์„œ๋งŒ ๋ฐ›์•„์•ผ ํ•œ๋‹ค'๋Š” ๋ฃฐ์„ "'๋ทฐ'์—๋Š” ๋‹ค๋ฅด๊ฒŒ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋งŒ ๋‹ด์„ ์ˆ˜ ์žˆ๋‹ค"๊ณ  ์ž˜๋ชป ์ดํ•ดํ•˜๊ณ  ์žˆ์—ˆ๋‹ค.
  • InputView๋Š” '๋ชจ๋ธ๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์ง€ ์•Š๋Š”๋‹ค'. ๊ทธ๋ ‡๋‹ค๋ฉด ๋‹ค๋ฅด๊ฒŒ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๊ฒƒ์€ ๋ฌธ์ œ๊ฐ€ ์—†๋‹ค..!
  • ๊ทธ๋ž˜์„œ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์ˆ˜ํ–‰ํ•˜๋˜ ์ž…๋ ฅ ์š”์ฒญ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ ๊ธฐ๋Šฅ์„ InputView๋กœ ๋นผ์ฃผ์—ˆ๋‹ค. (์‚ฌ์‹ค ์ด๊ฒƒ๊นŒ์ง€ ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ๋„ ๋„ˆ๋ฌด ๊ณผ์ค‘๋œ๋‹ค.)

+ ๊ฒŒ์ž„ ์‹œ์ž‘์— ๊ด€ํ•œ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ์€ InputView๋กœ ๋นผ์ง€ ์•Š๊ณ  Controller์—์„œ ์ˆ˜ํ–‰ํ•˜๋„๋ก ๋‘์—ˆ๋‹ค. 

์ด์œ ๋Š” InputView๋Š” ์ž…๋ ฅ์— ๊ด€ํ•œ ๋ฉ”์‹œ์ง€, OutputView๋Š” ๊ฒฐ๊ณผ์— ๊ด€ํ•œ ๋ฉ”์‹œ์ง€๋ฅผ ๋‹ด๊ณ  ์žˆ์ง€๋งŒ ๊ฒŒ์ž„ ์‹œ์ž‘์— ๊ด€ํ•œ ๋ฉ”์‹œ์ง€๋Š” ๋‘ ๊ณณ ๋ชจ๋‘ ํ•ด๋‹นํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ด๊ธฐ๋„ ํ•˜๊ณ , ๊ฒŒ์ž„ ์‹œ์ž‘์— ๊ด€ํ•œ ๋ฉ”์‹œ์ง€๋Š” ํ•˜๋‚˜ ๋ฟ์ด๋ผ ์ด๋ฅผ ์œ„ํ•œ ํด๋ž˜์Šค๋ฅผ ํŒŒ๋Š” ๊ฒƒ ๋ณด๋‹ค, ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์ด ํ•˜๋‚˜์ฏค์€ ์ˆ˜ํ–‰ํ•ด๋„ ๋ฌธ์ œ์—†์„ ๊ฑฐ๋ผ ์ƒ๊ฐํ•ด์„œ.

public class BaseballGameController {

    private static final String START_MSG = "์ˆซ์ž ์•ผ๊ตฌ ๊ฒŒ์ž„์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.";
    
    ...
   public void printStartMessage() {
        System.out.println(START_MSG);
    }
}

 

2. Controller์˜ playOneRound ๋ฉ”์†Œ๋“œ์˜ indent depth ์ค„์ด๋Š” ๋ฐ ์„ฑ๊ณต

์ˆ˜์ • ์ „

public void start() {
    printStartMessage();
    while (player.getRestartOrExit() != EXIT) {
        playOneRound(computer.getGeneratedNumbers());
        player.inputRestartOrExit();
    }
}

private void playOneRound(List<Integer> answer) {
    while (true) {
        printSuggestNumberMessage();
        player.inputNumbers();
        Score score = computer.calculateScore(player.getNumbers(), answer);
        outputView.printResult(score);
        if (score.isAllStrike()) {
            printRestartOrExitMessage();
            break;
        }
    }
}

 

์ˆ˜์ • ํ›„

public void start() {
    printStartMessage();
    while (player.getRestartOrExit() != EXIT) {
        playOneRound(computer.generateNumber(), new Score(INIT_STRIKE, INIT_BALL));
        player.inputRestartOrExit();
    }
}

private void playOneRound(List<Integer> answer, Score score) {
    while (!score.isAllStrike()) {
        inputView.printSuggestNumberMessage();
        player.inputNumbers();
        score = computer.calculateScore(player.getNumbers(), answer);
        outputView.printResult(score);
    }
    inputView.printRestartOrExitMessage();
}
  • score์— initial ๊ฐ’์„ ๋„ฃ๊ณ  argument๋กœ ๋„˜๊ธฐ๋‹ˆ if๋ฌธ์„ ์จ์ฃผ์ง€ ์•Š๊ณ  ๋ฐ”๋กœ while๋ฌธ์—์„œ ๊ฒ€์‚ฌํ•˜๊ฒŒ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ์ด๋กœ์จ indent depth๋Š” 1์ด ๋˜์—ˆ๋‹ค. ๋ฟŒ๋“ฏํ•˜๋‹ค.

 

+ ๊ฐ€๋…์„ฑ์„ ์œ„ํ•ด ๋ฉ”์†Œ๋“œ๋ช…์„ ๋ฐ”๊พธ๊ณ , ์ปจ๋ฒค์…˜์— ๋งž์ง€ ์•Š๋Š” ์ฝ”๋“œ๋“ค์„ ์ˆ˜์ •ํ•ด ๋‚˜๊ฐ€๋ฉด์„œ ์ œ์ถœ์šฉ ๋ธŒ๋žœ์น˜์— ๊ธฐ๋Šฅ๋ณ„๋กœ ์ปค๋ฐ‹ํ•˜๋‹ˆ ํ•˜๋ฃจ๊ฐ€ ๋‹ค ์ง€๋‚˜๊ฐ”๋‹ค. 


10/23 - Day 5

์›๋ž˜ ์˜ค๋Š˜์€ ์•ฝ๊ฐ„์˜ ๋ฆฌํŽ™ํ† ๋ง ์ดํ›„ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ์— ํž˜์„ ์ฃผ๋ ค ํ–ˆ์ง€๋งŒ ์–ด์ฐŒํ•˜๋‹ค๋ณด๋‹ˆ ๋ฆฌํŽ™ํ† ๋ง๊ณผ ๋””๋ฒ„๊น…ํ•˜๋Š”๋ฐ ๋งŽ์€ ์‹œ๊ฐ„์„ ์Ÿ๊ฒŒ ๋˜์—ˆ๋‹ค.

1. util ํŒจํ‚ค์ง€

model๋„์•„๋‹ˆ๊ณ  view๋„์•„๋‹ˆ๊ณ  controller๋„ ์•„๋‹Œ ํด๋ž˜์Šค๋“ค์€ 'util'์ด๋ผ๋Š” ํŒจํ‚ค์ง€๋กœ ๋ฌถ์œผ๋‹ˆ ์ง๊ด€์„ฑ์ด ๋–จ์–ด์ ธ ๋ณด์˜€๋‹ค. ๋ฌด์—‡๋ณด๋‹ค๋„ util์— ๋งŽ์€ ํด๋ž˜์Šค๋“ค์ด ๋ถ„ํฌํ•˜๋‹ค ๋ณด๋‹ˆ, ์ด ์—ญํ• ์„ ๋„๋ฉ”์ธ์—์„œ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ ์‹ถ๊ธฐ๋„ ํ–ˆ๋‹ค.

util ํŒจํ‚ค์ง€๋ฅผ ๋ณด๋ฉด NumberGenerator, ScoreCalculator๋Š” Computer์—์„œ ์‚ฌ์šฉํ•˜๊ณ , InputValidator, StringToIntegerListConverter๋Š” Player์—์„œ ์‚ฌ์šฉํ•œ๋‹ค.  NumberGenerator๊ฐ€ ํ•˜๋Š” ๊ธฐ๋Šฅ์„ Computer์— ๊ตฌํ˜„ํ•˜๋ฉด NumberGenerator ํด๋ž˜์Šค๋ฅผ ์‚ญ์ œํ•ด๋„ ๋˜์ง€ ์•Š์„๊นŒ? ์ƒ๊ฐํ•˜๋‹ค๊ฐ€ ๋– ์˜ฌ๋ฆฐ ๊ฒƒ์ด '์ผ๊ธ‰ ์ปฌ๋ ‰์…˜'์ด๋‹ค. 

 

"์ผ๊ธ‰ ์ปฌ๋ ‰์…˜"์„ ์ ์šฉํ•œ ๊ตฌ์กฐ๋Š” ์ด๋ ‡๋‹ค.

Computer๊ฐ€ GameAnswer, Score์˜ ์ธ์Šคํ„ด์Šค ๋ฉค๋ฒ„๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง„๋‹ค.

 

ํ•˜๋‚˜์”ฉ ์•Œ์•„๋ณด์ž.

 

Computer

 

GameAnswer

  • ์ด ๋•Œ GameAnswer๋Š” List<Integer> answer์™€, makeAnswer()๋ผ๋Š” ์ธ์Šคํ„ด์Šค ๋ฉค๋ฒ„๋ฅผ ๊ฐ€์ง€๋Š”๋ฐ, makeAnswer()์— NumberGenerator๊ฐ€ ํ•˜๋Š” ์—ญํ• ์„ ๊ตฌํ˜„ํ•˜์—ฌ answerํ•„๋“œ์— ์ƒ์„ฑํ•œ ์ˆซ์ž๋ฅผ ํ• ๋‹นํ•ด์ฃผ๋Š”๋ฐฉ์‹์ด๋‹ค.

Score

  • Integer strike, Integer ball์ด๋ผ๋Š” ํ•„๋“œ์™€, calculate()๋ผ๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.
  • calculate() ๋ฉ”์†Œ๋“œ์— ScoreCalculator๊ฐ€ ํ•˜๋Š” ์—ญํ• ์„ ๊ตฌํ˜„ํ•˜์—ฌ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•œ๋‹ค. ๊ณ„์‚ฐํ•œ ๊ฐ’์€ strike, ball์— ๊ฐ’์„ ํ• ๋‹นํ•ด์ค€๋‹ค.

 

Player

 

GuessNumbers

  • List<GuessNumber> guessNumbers ํ•„๋“œ์™€, validateGuessNumbers() ๋ฉ”์†Œ๋“œ๋ฅผ ๊ฐ€์ง„๋‹ค.
  • ์—ฌ๊ธฐ์„œ GuessNumber๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ 3๊ฐœ์˜ ์ˆซ์ž ์ค‘ ํ•˜๋‚˜์˜ ์ˆซ์ž๋ฅผ ๋งํ•œ๋‹ค. 
    • GuessNumber
    • Integer number ํ•„๋“œ์™€ validateGuessNumber() ๋ฉ”์†Œ๋“œ๋ฅผ ๊ฐ€์ง„๋‹ค.
    • validateGuessNumber() ๋ฉ”์†Œ๋“œ๋กœ ์ž…๋ ฅํ•œ ์ˆซ์ž 'ํ•˜๋‚˜'์— ๋Œ€ํ•œ ๊ฒ€์ฆ์ด ์ด๋ฃจ์–ด์ง„๋‹ค. 
  • validateGuessNumbers()์—์„œ๋Š” ์ž…๋ ฅํ•œ ์ˆซ์ž 3๊ฐœ์— ๋Œ€ํ•œ ๊ฒ€์ฆ์ด ์ด๋ฃจ์–ด์ง„๋‹ค. ๊ฒ€์ฆ์— ์„ฑ๊ณตํ•˜๋ฉด List<GuessNumber> guessNumbers์— ๊ฐ’์ด ํ• ๋‹น๋œ๋‹ค.

 

์ผ๊ธ‰ ์ปฌ๋ ‰์…˜์„ ์ ์šฉํ•˜๋‹ˆ ํด๋ž˜์Šค๊ฐ€ ๋ถ„๋ฆฌ๋จ์œผ๋กœ์จ ์ฑ…์ž„์ด ๋ถ„๋ฆฌ๋˜๋‹ˆ ์ฝ”๋“œ๊ฐ€ ์กฐ๊ธˆ ๋” ๊ฐ์ฒด์ง€ํ–ฅ์ ์œผ๋กœ ๋ฐ”๋€Œ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

 

2. ApplicationTest์˜ ํ…Œ์ŠคํŠธ์ฝ”๋“œ๊ฐ€ ๋Œ์•„๊ฐ€์ง€ ์•Š๋Š” ๋ฌธ์ œ

  • ๊ตฌํ˜„์ด ์™„๋ฃŒ๋˜๋ฉด ApplicationTest์˜ ๋ชจ๋“  ํ…Œ์ŠคํŠธ๊ฐ€ ์„ฑ๊ณตํ•ด์•ผ ํ•œ๋‹ค. 
  • ๋ฌธ์ œ๋Š” ๋ฏธ์…˜์—์„œ ์ œ์‹œํ•œ ๋‘ ๊ฐ€์ง€์˜ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ํ•˜๋‚˜์”ฉ ๋Œ๋ฆฌ๋ฉด ์„ฑ๊ณตํ•˜๋Š”๋ฐ, ์ „์ฒด๋ฅผ ์‹คํ–‰ํ•˜๋‹ˆ ๋‘ ๋ฒˆ์งธ ํ…Œ์ŠคํŠธ์ฝ”๋“œ๊ฐ€ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ด์—ˆ๋‹ค.

์‹คํ–‰ ๊ฒฐ๊ณผ

๋ถ„๋ช… ๋ฉ”์ธ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๊ธธ์ด๊ฐ€ 3์ดˆ๊ณผ์ธ ์ž…๋ ฅ์— ๋Œ€ํ•ด์„œ ์˜ˆ์™ธ๊ฐ€ ์ž˜ ๋ฐœ์ƒํ•˜๋Š”๋ฐ ๋„์ €ํžˆ ์•Œ ์ˆ˜ ์—†๋Š” ๋…ธ๋ฆ‡์ด์—ˆ๋‹ค.

๊ฒฐ๊ตญ ์ด์ „ ํ…Œ์ŠคํŠธ๊ฐ€ ๋‹ค์Œ ํ…Œ์ŠคํŠธ์— ์˜ํ–ฅ์„ ์ค€๋‹ค๋Š” ๊ฒƒ์ธ๋ฐ.. ์™œ ์˜ํ–ฅ์„ ์ฃผ๋Š” ๊ฒƒ์ผ๊นŒ?

 

"ํ•˜๋‚˜์”ฉ ๋Œ์•„๊ฐ€๋ฉด ์„ฑ๊ณต" + "์ „์ฒด๋ฅผ ๋Œ๋ฆฌ๋ฉด ์‹คํŒจ" + "์˜ˆ์™ธ๋ฅผ ์žก์ง€ ๋ชปํ–ˆ๋‹ค๋Š” ๋ฉ”์‹œ์ง€๋งŒ ์ถœ๋ ฅ"  + "๋ฉ”์ธ์—์„œ๋Š” ์˜ˆ์™ธ๋ฅผ ์ž˜ ์žก์Œ" =  ๋„๋Œ€์ฒด ๋ฌธ์ œ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€..

 

๋ฉ”์ธ ๋กœ์ง์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋‚˜ ์‚ดํŽด๋ดค์ง€๋งŒ ๋ฌธ์ œ๋„ ์—†์—ˆ๋‹ค.

 

๊ฒฐ๊ตญ ์ด๊ฒƒ์ €๊ฒƒ ์‹œ๋„ํ•ด๋ณด๋‹ค๊ฐ€ ํ˜น์‹œ๋‚˜ GameStateNumber enum์ด ๋ฌธ์ œ์ธ๊ฐ€ ์‹ถ์–ด, enum์„ class๋กœ ๋ณ€๊ฒฝํ•ด ๋ณด์•˜๋‹ค.

public enum GameStateNumber {

    DEFAULT(0), RESTART(1), EXIT(2);

    private Integer stateNumber;

    GameStateNumber(Integer stateNumber) {
        this.stateNumber = stateNumber;
    }

    public void input() {
        String input = Console.readLine();
        validateGameStateNumber(input);
        this.stateNumber = Integer.parseInt(input);
    }

    private void validateGameStateNumber(String input) {
        if (!isGameStateNumberValid(input)) {
            throw new IllegalArgumentException();
        }
    }

    public boolean isExit() {
        if (this.stateNumber == EXIT.stateNumber) {
            return true;
        }
        return false;
    }
}

 

์ถ”์ธก์ปจ๋ฐ, ์ œ์‹œํ•ด ์ค€ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ์—์„œ๋Š” enum์—์„œ ๋˜์ง„ ์˜ˆ์™ธ๋ฅผ ๋ฐ›์ง€ ๋ชปํ•˜๋Š” ๊ฒƒ ๊ฐ™์•˜๋‹ค. ์ œ์‹œํ•ด์ค€ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜๋Š” ์—†๋Š” ์ƒํ™ฉ์ด๋ผ ๊ทธ๋ƒฅ enum์„ class๋กœ ๋ฐ”๊พธ์–ด์„œ ์ง„ํ–‰ํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.

 

์ˆ˜์ • ํ›„

public class GameStateNumber {

    private static final Integer START = 1;
    private static final Integer EXIT = 2;

    private Integer stateNumber;

    public GameStateNumber() {
        this.stateNumber = START;
    }

    public void input() {
        String input = Console.readLine();
        validateGameStateNumber(input);
        this.stateNumber = Integer.parseInt(input);
    }

    private void validateGameStateNumber(String input) {
        if (!isGameStateNumberValid(input)) {
            throw new IllegalArgumentException();
        }
    }

    public boolean isExit() {
        if (this.stateNumber == EXIT) {
            return true;
        }
        return false;
    }
}

 

'์„ค๋งˆ ์ด๊ฑด๊ฐ€?' ํ–ˆ๋˜ ๊ฒƒ์ด ์–ป์–ด ๊ฑธ๋ฆฐ ๋Š๋‚Œ์ด๋ผ ํ›„๋ จํ•˜๊ธฐ๋„ ํ–ˆ์ง€๋งŒ, ๋””๋ฒ„๊น… ๊ณผ์ •์ด ์ฐธ์œผ๋กœ ์ˆœํƒ„์น˜ ์•Š์•˜๋‹ค. 


10/25 - Day 6

์˜ค๋Š˜์€ ๊ธฐ์–ด์ฝ” ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ฒ ๋‹ค๊ณ  ๋‹ค์งํ–ˆ๊ฑด๋งŒ, ์ž๊พธ ๋” ์ฝ”๋“œ๋ฅผ ์ข‹๊ฒŒ ๋ฐ”๊พธ๊ณ  ์‹ถ์€ ์š•์‹ฌ์ด ๋” ์ปธ๋‹ค.

 

์—ฌ๋Ÿฌ ์‹œํ–‰์ฐฉ์˜ค๊ฐ€ ๋งŽ์•˜์ง€๋งŒ, ๊ตต์ง๊ตต์งํ•œ ๋ฆฌํŽ™ํ† ๋ง๋“ค๋งŒ ๋ชจ์•„์„œ ์‚ดํŽด๋ณด์ž.

1. CommonView ๋„์ž…

 OutputView์—์„œ๋Š” ๊ฒŒ์ž„์— ๋Œ€ํ•œ ํ”Œ๋ ˆ์ด์–ด์˜ ์ ์ˆ˜๋ฅผ, InputView์—์„œ๋Š” ์ž…๋ ฅ์— ๋Œ€ํ•œ ์•ˆ๋‚ด ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด ์‚ฌ์šฉ์ž์—๊ฒŒ ๊ณตํ†ต์œผ๋กœ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•  ๋ฉ”์‹œ์ง€๋Š” ์–ด๋””์— ๋‘์–ด์•ผ ํ• ๊นŒ?

 

๊ณตํ†ต์ ์œผ๋กœ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•  ๋ฉ”์‹œ์ง€๊ฐ€ ํ•˜๋‚˜๋ฟ์ด๋ผ ์ด๊ฑธ ์œ„ํ•ด View๋ฅผ ๋งŒ๋“ค๊ธฐ๋„ ์• ๋งคํ•ด ๋ณด์˜€๊ณ , Controller์—์„œ ์ด ํ•˜๋‚˜์ฏค์€ ์ˆ˜ํ–‰ํ•ด๋„ ๋˜์ง€์•Š๋‚˜ ์‹ถ๊ธฐ๋„ ํ–ˆ๋‹ค. ๊ทธ๋ž˜์„œ Controller์—์„œ ๊ฒŒ์ž„ ์‹œ์ž‘์— ๊ด€ํ•œ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•˜๊ณ  ์žˆ์—ˆ๋‹ค. ํ•˜์ง€๋งŒ ๊ณตํ†ต์œผ๋กœ ๋ณด์—ฌ์ฃผ์–ด์•ผ ํ•  ๋ฉ”์‹œ์ง€๊ฐ€ ๋งŽ์•„์ง€๋ฉด  ์–ด์ฐจํ”ผ View ํด๋ž˜์Šค๋ฅผ ํ•˜๋‚˜ ๋” ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋‹ˆ, ๋ฏธ๋ฆฌ ์—ญํ• ์— ๋งž๊ฒŒ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ์˜ณ๋‹ค๊ณ  ์ƒ๊ฐํ•˜์—ฌ CommonView ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค. CommonView์—์„œ๋Š” ์‚ฌ์šฉ์ž์—๊ฒŒ ๊ณตํ†ต์œผ๋กœ ๋ณด์—ฌ ์ฃผ์–ด์•ผํ•  ๋ฉ”์‹œ์ง€์˜ ์ถœ๋ ฅ์„ ๋‹ด๋‹นํ•˜๋„๋ก ์„ค์ •ํ–ˆ๋‹ค.

 

 

2. InputValidator ๋ถ„๋ฆฌ  

๊ธฐ์กด InputValidator์—์„œ ๋งŽ์€ ๊ธฐ๋Šฅ์„ ๋‹ด๋‹นํ•˜๊ณ  ์žˆ์—ˆ๋‹ค. -> ์ˆซ์ž 1๊ฐœ์— ๋Œ€ํ•œ ๊ฒ€์ฆ, ์ˆซ์ž 3๊ฐœ์— ๋Œ€ํ•œ ๊ฒ€์ฆ, ๊ฒŒ์ž„ ์ƒํƒœ ์ˆซ์ž์— ๋Œ€ํ•œ ๊ฒ€์ฆ 

 

๊ทธ๋ž˜์„œ ์ด InputValidator๋ฅผ 3๊ฐœ์˜ ํด๋ž˜์Šค๋กœ ๋‚˜๋ˆ„์–ด ์ˆซ์ž 1๊ฐœ์— ๋Œ€ํ•œ ๊ฒ€์ฆ, ์ˆซ์ž 3๊ฐœ์— ๋Œ€ํ•œ ๊ฒ€์ฆ, ๊ฒŒ์ž„ ์ƒํƒœ ์ˆซ์ž์— ๋Œ€ํ•œ ๊ฒ€์ฆ์„ ๋ถ„๋ฆฌํ•˜์˜€๋‹ค.

 

  • GuessNumberValidator(์ˆซ์ž ํ•˜๋‚˜๋ฅผ ๊ฒ€์‚ฌ - 1~9์‚ฌ์ด์˜ ์ˆซ์ž์ธ์ง€)
  • GuessNumbersValidator(์ˆซ์ž 3๊ฐœ๋ฅผ ๊ฒ€์‚ฌ - ์ค‘๋ณต, ๊ธธ์ด ) 
  • GameStateNumberValidator(์ˆซ์ž 1 or 2์ธ์ง€ ๊ฒ€์‚ฌ)

 

3. ScoreCalculator๋ฅผ ๋‹ค์‹œ ๋งŒ๋“ฆ

Score์— ScoreCaluator๊ฐ€ ํ•˜๋Š” ๊ธฐ๋Šฅ๋“ค์„ ๊ตฌํ˜„ํ•˜๋‹ˆ ๋„๋ฉ”์ธ ์ฝ”๋“œ๊ฐ€ ์—„์ฒญ ๊ธธ์–ด์กŒ์—ˆ๋‹ค. ์ด๋Œ€๋กœ ๊ฐˆ๊นŒ, ๋‹ค์‹œ ๋ถ„๋ฆฌํ• ๊นŒ ๊ณ ๋ฏผํ•˜๋‹ค๊ฐ€ ScoreCalculator๋ฅผ util๋กœ ๋‹ค์‹œ ๋บด๋‚ด๊ณ  Score ํด๋ž˜์Šค์˜ calculate() ๋ฉ”์†Œ๋“œ๋Š” ScoreCalculator์˜ ์ •์  ๋ฉค๋ฒ„ ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ๋ณ€๊ฒฝํ–ˆ๋‹ค. 

 


10/25 - Day 7

0. ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ 

์˜ค๋Š˜์€ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ์— ํž˜์„ ๋“ค์˜€๋‹ค.

์›๋ž˜๋ผ๋ฉด  '1.๊ตฌํ˜„ -> 2.ํ…Œ์ŠคํŠธ' ์ˆœ์„œ๋กœ ์ง„ํ–‰ํ•ด์•ผ ํ•˜์ง€๋งŒ, ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ์— ์ต์ˆ™์น˜ ์•Š์•„์„œ ๋ชจ๋“  ๊ตฌํ˜„์ด ๋๋‚œ ํ›„ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ์ˆœ์„œ๋กœ ์ง„ํ–‰ํ–ˆ๋‹ค. ์ˆœ์„œ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๋‹ค๊ฐ€ ํ…Œ์ŠคํŠธ๋ฅผ ๋จผ์ € ์ž‘์„ฑํ•˜๊ณ  ์‹ค์ œ ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” TDD(Test Driven Development)๋ผ๋Š” ๋ฐฉ๋ฒ•๋ก ์ด ๋Œ€ํ•ด์„œ๋„ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค.

 

 

TDD๋ž€? ํ…Œ์ŠคํŠธ ์ฃผ๋„ ๊ฐœ๋ฐœ - ํ•˜๋‚˜๋ชฌ

TDD๋ž€ Test Driven Development์˜ ์•ฝ์ž๋กœ 'ํ…Œ์ŠคํŠธ ์ฃผ๋„ ๊ฐœ๋ฐœ'์ด๋ผ๊ณ  ํ•œ๋‹ค.

hanamon.kr

 

์ฝ์–ด๋ณด๋ฉด ์ข‹์€ ๊ฐœ๋ฐœ ๋ฐฉ์‹์ด๋ผ๊ณ  ์ƒ๊ฐ์€ ๋˜์ง€๋งŒ, ๋‹น์žฅ ํ”„๋ฆฌ์ฝ”์Šค์—์„œ ์ง„ํ–‰ํ•˜๊ธฐ์—” ๊ฐœ๋ฐœ ๋ฐฉ์‹์„ ์•„์˜ˆ ๋ฐ”๊พธ์–ด์•ผ ํ•  ๊ฒƒ ๊ฐ™์•„ ์ƒ์‚ฐ์„ฑ์ด ๋งŽ์ด ๋–จ์–ด์งˆ ๊ฒƒ ๊ฐ™๋‹ค. ์ด ๋ถ€๋ถ„์€ ํ”„๋ฆฌ์ฝ”์Šค๊ฐ€ ๋๋‚˜๋ฉด ํ•œ ๋ฒˆ ๊ณต๋ถ€ํ•ด ๋ด์•ผ๊ฒ ๋‹ค.

 

๊ฐ์„คํ•˜๊ณ  ์ด๋ฒˆ ๋ฏธ์…˜์—์„œ ๋ชจ๋“  ๊ตฌํ˜„์ด ๋๋‚œ ํ›„ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๋‹ค๊ณ  ํ–ˆ๋Š”๋ฐ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด์„œ ์ด ์ˆœ์„œ๋Š” ์ •๋ง ์ข‹์ง€ ์•Š๋‹ค๊ณ  ๋Š๊ผˆ๋‹ค. ์ฝ”๋“œ์— ๋ฒ„๊ทธ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์ง์ ‘ ๋ฉ”์ธ์„ ์‹คํ–‰์‹œ์ผœ ๋ฒ„๊ทธ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ์ง€์ ์„ ์ฐพ๊ธฐ ์ผ์‘ค์˜€๋Š”๋ฐ, ๊ธฐ๋Šฅ ๊ตฌํ˜„ ์ดํ›„ ๋ฐ”๋กœ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•œ๋‹ค๋ฉด ์ด๋Ÿฐ ๋‚ญ๋น„๋˜๋Š” ์‹œ๊ฐ„๋“ค์„ ๋งŽ์ด ์ค„์ผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค. 2์ฃผ์ฐจ ๋ฏธ์…˜๋ถ€ํ„ฐ๋Š” ์ด ํ…Œ์ŠคํŠธ๋ฅผ ์ž˜ ํ™œ์šฉํ•ด์•ผ๊ฒ ๋‹ค.

 

* ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋Š” ์ตœํ•˜๋‹จ ๋งํฌ ์ฐธ์กฐ


์ „๋ฐ˜์ ์ธ 1์ฃผ์ฐจ ํ›„๊ธฐ 

์ž๋Š” ์‹œ๊ฐ„์ด ์•„๊นŒ์šธ ์ •๋„๋กœ ์ฆ๊ฑฐ์› ๋˜ ํ•œ ์ฃผ ์˜€์Šต๋‹ˆ๋‹ค.

 

์•Œ๊ณ ๋ฆฌ์ฆ˜๋งŒ ๋ณด๋ฉด ์ฒซ ์ฃผ์ฐจ ๋ฏธ์…˜์˜ ๊ธฐ๋Šฅ์ ์ธ ์š”๊ตฌ์‚ฌํ•ญ๋“ค์€ ์–ด๋ ต์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๊ทธ๋งŒํผ ๋ฌธ์ œ๋ฅผ ์ถœ์ œํ•˜์‹  ๋ถ„๋“ค๊ป˜์„œ ์ด๋ฒˆ ๋ฏธ์…˜์—์„œ๋Š” ๋ถ„๋ช… ‘์ข‹์€ ์„ค๊ณ„’์— ๋Œ€ํ•ด ๊ณ ๋ฏผํ•˜๊ณ  ์ƒ๊ฐํ•ด๋ณด๋ผ๋Š” ์ทจ์ง€๋กœ ๋ฏธ์…˜์„ ๋‚ด์‹  ๊ฒƒ์ด๋ผ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌํ•˜์—ฌ ์ €๋Š” ์ด๋ฒˆ ๋ฏธ์…˜์—์„œ ‘์ข‹์€ ์„ค๊ณ„’๋ผ๋Š” ํ•˜๋‚˜์˜ ๋ชฉํ‘œ๋ฅผ ๋‹ฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ, 3๊ฐ€์ง€์˜ ๋ชฉํ‘œ๋กœ ์„ธ๋ถ„ํ™”ํ•˜์—ฌ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.

 

1. ๊ฐ€๋…์„ฑ ์ข‹์€ ์ฝ”๋“œ ์ž‘์„ฑํ•˜๊ธฐ

์ฝ”๋“œ๋ฅผ ์ฝ๋Š” ์‚ฌ๋žŒ์ด ์ฝ๊ธฐ ํŽธํ•˜๊ฒŒ ์ž‘์„ฑํ•˜๋Š”๊ฒŒ ๊ฐ€์žฅ ์ค‘์š”ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฒˆ ์ฃผ์ฐจ๊ฐ€ ๋๋‚˜๋ฉด ํ”ผ์–ด ์ฝ”๋“œ ๋ฆฌ๋ทฐ๋ฅผ ์ง„ํ–‰ํ• ํ…๋ฐ, ์ œ๊ฐ€ ์•„๋ฌด๋ฆฌ ์„ค๊ณ„๋ฅผ ์ž˜ํ–ˆ๋‹ค ํ•œ๋“ค, ๊ฐ€๋…์„ฑ์ด ์—‰๋ง์ด๋ผ๋ฉด ๋ˆ„๊ตฌ๋ผ๋„ ์ฝ๊ธฐ ์‹ซ์„ ๊ฒƒ์ด ๋ถ„๋ช…ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

 

ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์š”๊ตฌ์‚ฌํ•ญ์— ์ œ์‹œํ•ด์ฃผ์‹  ์ปจ๋ฒค์…˜ ๋ง๊ณ ๋„ ์„œ์นญํ•ด๋ณด๋‹ˆ ์ž๋ฐ” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด์„œ ์ง€์ผœ์•ผ ํ•  ์ปจ๋ฒค์…˜๋“ค์ด ๋ฌธ์„œํ™”๋˜์–ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ด ์ค‘์— ์•Œ๊ณ  ์žˆ๋˜ ๊ฒƒ๋“ค๋„ ์žˆ๊ณ , ๋ชจ๋ฅด๊ณ  ์žˆ๋˜ ๊ฒƒ๋“ค๋„ ๋งŽ์•˜์Šต๋‹ˆ๋‹ค. ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ ธ ๋ณด์ด๋Š” ์ œ ์ฝ”๋“œ๋“ค์€ ์ปจ๋ฒค์…˜์„ ์–ด๊ธฐ๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์•˜๋Š”๋ฐ, ํ™•์‹คํžˆ ๋ฌธ์„œ๋ฅผ ์ฝ๊ณ  ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ณ , ์ฝ๊ณ  ์ž‘์„ฑํ•˜๊ณ  ๋ฐ˜๋ณตํ•˜๋‹ค ๋ณด๋‹ˆ ์ปจ๋ฒค์…˜์„ ์ง€ํ‚ค๋Š” ๊ฒƒ์ด ๊ฐ€๋…์„ฑ์„ ๋Œ์–ด์˜ฌ๋ฆฌ๋Š” ๋ฐ ๋งŽ์€ ๋„์›€์ด ๋˜๋Š” ๊ฒƒ์„ ์ฒด๊ฐํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ปจ๋ฒค์…˜ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋ฉ”์†Œ๋“œ๋ช…, ํ•„๋“œ๋ช…, ํด๋ž˜์Šค๋ช…์— ๋Œ€ํ•œ ๊ณ ๋ฏผ๋„ ์ •๋ง ๋งŽ์ดํ–ˆ์Šต๋‹ˆ๋‹ค. ‘์–ด๋–ป๊ฒŒ ์ž‘์„ฑํ•ด์•ผ ์ด๋ฆ„์„ ๋ณด๊ณ  ์˜๋„๋ฅผ ๋ฐ”๋กœ ์บ์น˜ํ•  ์ˆ˜ ์žˆ์„๊นŒ?’์— ๋Œ€ํ•ด ๋งŽ์ด ์ƒ๊ฐํ•˜๋ฉฐ, ๋”์šฑ ๊ฐ€๋…์„ฑ ์ข‹์€ ์ฝ”๋“œ๊ฐ€ ๋  ์ˆ˜ ์žˆ๋„๋ก ๋…ธ๋ ฅํ•  ์ˆ˜ ์žˆ์—ˆ๋˜ ํ•œ ์ฃผ ์˜€์Šต๋‹ˆ๋‹ค.

 

 

2. ๊ฐ์ฒด์ง€ํ–ฅ ์ƒํ™œ์ฒด์กฐ 9๊ฐ€์ง€ ๊ทœ์น™ ์ค€์ˆ˜ํ•˜๊ธฐ

ํ”„๋ฆฌ์ฝ”์Šค๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ ์ „, ๊ฐ์ฒด์ง€ํ–ฅ ์ƒํ™œ์ฒด์กฐ 9๊ฐ€์ง€ ๊ทœ์น™์„ ๊ณต๋ถ€ํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒ˜์Œ์—๋Š” ์ด 9๊ฐ€์ง€ ๊ทœ์น™์„ ๋ณด๊ณ  ‘์ด ๊ทœ์น™๋“ค์„ ์–ด๋–ป๊ฒŒ ์•ˆ ์–ด๊ธฐ๋ฉด์„œ ์ฝ”๋“œ๋ฅผ ์งค ์ˆ˜๊ฐ€ ์žˆ์ง€..?’๋ผ๊ณ  ์ƒ๊ฐํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค.

 

์™œ ์ด๋Ÿฐ ๊ทœ์น™๋“ค์„ ์ •ํ•ด ๋†“์•˜๋Š” ์ง€๋Š” ๊ตฌํ˜„์„ ํ•˜๊ณ  ๋‚œ ํ›„ ๊ทœ์น™์— ์ž…๊ฐํ•ด์„œ ๋ฆฌํŽ™ํ† ๋ง์„ ์ง„ํ–‰ํ•  ๋•Œ ์ •ํ™•ํžˆ ์บ์น˜ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

ํŠนํžˆ ์ผ๊ธ‰ ์ปฌ๋ ‰์…˜์„ ์ ์šฉํ•  ๋•Œ ์ •๋ง ํฌ๊ฒŒ ๊ฐ๋ช… ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค. ์ €๋Š” ์ˆซ์ž๊ฒŒ์ž„์—์„œ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…๋ ฅํ•˜๋Š” ์ˆซ์ž๊ฒŒ์ž„์— ๋Œ€ํ•œ 3๊ฐœ์˜ ์ˆซ์ž๋ฅผ ์ผ๊ธ‰ ์ปฌ๋ ‰์…˜์œผ๋กœ ๊ด€๋ฆฌํ–ˆ๋Š”๋ฐ, ์ด๋ ‡๊ฒŒ ์„ค๊ณ„ํ•˜๋‹ˆ “1๊ฐœ์˜ ์ˆซ์ž”์— ๋Œ€ํ•œ ๊ฒ€์ฆ์„ ๋‹จ์ผ ํด๋ž˜์Šค์—์„œ ๊ฒ€์ฆํ•˜๊ณ , “3๊ฐœ์˜ ์ˆซ์ž”์— ๋Œ€ํ•œ ๊ฒ€์ฆ์€ ์ผ๊ธ‰ ์ปฌ๋ ‰์…˜์—์„œ ํ•˜๋‹ˆ ๊ธฐ๋Šฅ๋„ ๋ถ„๋ฆฌ๋˜๊ณ , ์—ญํ• ๊ณผ ์ฑ…์ž„์ด ๊น”๋”ํ•˜๊ฒŒ ๋‚˜๋ˆ„์–ด์กŒ๋‹ค๋Š” ๊ฒƒ์„ ํฌ๊ฒŒ ์ฒด๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.

 

์ด๋Ÿฐ ๊ทœ์น™๋“ค์ด ์–ด๋Š์ •๋„ ์ฒดํ™”๋˜๊ณ  ์ข‹์€ ์„ค๊ณ„์— ๋Œ€ํ•ด ๊ณ ๋ฏผํ•  ์‹œ์ ์—๋Š” ์ด ๊ทœ์น™๋“ค์„ ์ ์šฉํ•˜๋‹ˆ ์ข‹์€ ์„ค๊ณ„๊ฐ€ ๋˜์—ˆ๋‹ค๋Š” ๋Š๋‚Œ๋ณด๋‹ค, “๊ฐ์ฒด์ง€ํ–ฅ์ ์ธ ์„ค๊ณ„๋ฅผ ์ง€ํ–ฅํ•˜๋‹ˆ ์ด๋Ÿฐ ๊ทœ์น™๋“ค์ด ์ž๋™์ ์œผ๋กœ ๋”ฐ๋ผ์˜จ๋‹ค” ๋Š๋‚Œ์„ ํฌ๊ฒŒ ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค. ๊ฐœ์ธ์ ์œผ๋กœ ์ด๋ฒˆ ํ•œ์ฃผ๊ฐ„ '์ด๋Ÿฐ ์ฝ”๋“œ ๊ฐ์ฒด์ง€ํ–ฅ์ ์ธ ์„ค๊ณ„๊ตฌ๋‚˜, ์ด๋ ‡๊ฒŒ ์ž‘์„ฑํ•˜๋ฉด ์ข‹์€ ์ฝ”๋“œ๊ฐ€ ๋  ์ˆ˜ ์žˆ๊ฒ ๋‹ค.’๊ณ  ๋งŽ์ด ๋Š๊ผˆ๋˜ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

 

3. MVC ํŒจํ„ด ์ •๋ฆฝํ•˜๊ธฐ

์ฒ˜์Œ์—๋Š” ๊ธฐ๋Šฅ ์š”๊ตฌ์‚ฌํ•ญ๋“ค์„ ์ž‘์„ฑํ•˜๊ณ  ์ปดํ“จํ„ฐ์™€ ํ”Œ๋ ˆ์ด์–ด ๋‘ ๊ฐœ์˜ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ์ด ํด๋ž˜์Šค๋ฅผ ์„œ๋กœ ์˜์กด์‹œํ‚จ ํ›„, ์ปดํ“จํ„ฐ์™€ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์„œ๋กœ ๋ฌธ๋‹ตํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌ๋ฉด ํ•œ ํด๋ž˜์Šค์— ์ฝ”๋“œ๊ฐ€ ์—„์ฒญ ๊ธธ์–ด์ง€๊ณ  ๊ฐ์ฒด ์ง€ํ–ฅ์ ์ธ ์„ค๊ณ„์™€๋Š” ๊ฑฐ๋ฆฌ๊ฐ€ ๋ฉ€์–ด์ง€๊ธฐ๋„ํ•ด์„œ ์ฒ˜์Œ์— ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ•  ์ง€ ํ…Œ๋ธ”๋ฆฟ์—๋„ ๊ทธ๋ ค๋ณด๋ฉด์„œ ๊ณ ๋ฏผํ•˜๋Š” ์‹œ๊ฐ„์ด ์ •๋ง ๊ธธ์—ˆ์Šต๋‹ˆ๋‹ค.

 

๊ฐ์ข… ์‹œํ–‰์ฐฉ์˜ค๋ฅผ ๊ฒช๋‹ค๊ฐ€ Spring์„ ๊ณต๋ถ€ํ•˜๋ฉด์„œ ์•Œ๊ฒŒ ๋œ MVC ํŒจํ„ด์„ ์ ์šฉํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค๋Š” ์ƒ๊ฐ์œผ๋กœ MVC ํŒจํ„ด์„ ์ฑ„ํƒํ•ด์„œ ๋ฏธ์…˜์„ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ฒ˜์Œ์—๋Š” ๋‹จ์ˆœํ•˜๊ฒŒ ์ด ํŒจํ„ด์„ ์ ์šฉํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๊ฐ์ฒด ์ง€ํ–ฅ์ ์ธ ์„ค๊ณ„๋ฅผ ๊ฐ€์ ธ๊ฐ๊ณผ ๋™์‹œ์— ๋ฏธ์…˜์„ ํด๋ฆฌ์–ด ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•˜๋Š”๋ฐ, ํ˜„์‹ค์€ ์ „ํ˜€ ๊ทธ๋ ‡์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. MVC ํŒจํ„ด์„ ์ž˜ ์•Œ๊ณ  ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ด ํŒจํ„ด์— ๋งž์ถฐ์„œ ๊ตฌํ˜„ํ•˜๊ณ  ๋ณด๋‹ˆ, ์ฝ”๋“œ์— ์ข‹์€ ์„ค๊ณ„๋ผ ํ•˜๊ธฐ์—๋Š” ์กฐ๊ธˆ์”ฉ ๋ถˆํŽธํ•œ ๋ถ€๋ถ„๋“ค์ด ์žˆ๊ธฐ๋„ ํ–ˆ๊ณ , ๋†“์น˜๊ณ  ์žˆ๋Š” ๋ถ€๋ถ„๋“ค์ด ๋งŽ์•˜์Šต๋‹ˆ๋‹ค. ์•ž์œผ๋กœ์˜ ๋ฏธ์…˜๋“ค๋„ ์ด MVC ํŒจํ„ด์— ์ž…๊ฐํ•˜๋ฉด ๋งŽ์€ ๋„์›€์ด ๋  ๊ฑฐ๋ผ ์ƒ๊ฐํ•ด ์ด๋ฒˆ์„ ๊ธฐํšŒ ์‚ผ์•„ ํ™•์‹คํ•˜๊ฒŒ ๋‹ค์‹œ ํ•œ๋ฒˆ MVC ํŒจํ„ด์„ ๊ณต๋ถ€ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

 

ํŒจํ„ด์„ ๋‹ค์‹œ ํ•œ๋ฒˆ ๊ณต๋ถ€ํ•˜๊ณ  ์ฝ”๋“œ๋ฅผ ๋ณด๋‹ˆ ๋ฆฌํŽ™ํ† ๋งํ•  ๋ถ€๋ถ„๋“ค์ด ๋ณด์ด๊ธฐ ์‹œ์ž‘ํ–ˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์‹ค ๊ตฌํ˜„๋งŒ ๋ณด๋ฉด ์ •๋ง ๋นจ๋ฆฌ ๋๋‚ฌ๋Š”๋ฐ, ๋ฆฌํŽ™ํ† ๋งํ•˜๋Š” ๊ณผ์ •์ด ์ •๋ง ๊ธธ์—ˆ์Šต๋‹ˆ๋‹ค. ์ถ”๊ฐ€๋กœ MVC ํŒจํ„ด ๋‚ด์—์„œ๋„ ๋ฆฌํŒฉํ† ๋ง ๊ณผ์ •์ด ๋๋‚˜๊ณ  ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด ๋” ์ข‹์€ ๊ตฌ์กฐ๊ฐ€ ์ƒ๊ฐ๋‚˜๊ณ , ์ข‹์€ ๊ตฌ์กฐ๊ฐ€ ์ƒ๊ฐ๋‚˜๋ฉด ๊ณผ๊ฐํ•˜๊ฒŒ ๊ตฌ์กฐ๋ฅผ ๋œฏ์–ด ๊ณ ์น˜๋ฉด์„œ ์ข‹์€ ์ฝ”๋“œ๋ฅผ ๋งŒ๋“ค๋ ค๊ณ  ๋…ธ๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ๋•์— ์ƒ๊ฐํ•˜๊ณ  ๊ณ ์ณ๋ณด๊ณ , ์ƒ๊ฐํ•˜๊ณ  ๊ณ ์ณ๋ณด๊ณ  ํ•˜๋Š” ๊ณผ์ •์—์„œ๋Š” ๊ฐ์ฒด์ง€ํ–ฅ์ ์ธ ์‚ฌ๊ณ ๋ ฅ์„ ๋งŽ์ด ๋Œ์–ด ์˜ฌ๋ฆด ์ˆ˜ ์žˆ์—ˆ๋˜ ํ•œ ์ฃผ์˜€์Šต๋‹ˆ๋‹ค.

 

+ ์ฒ˜์Œ์—๋Š” ๋ฆฌํŽ™ํ† ๋งํ•œ ๊ฒƒ๋“ค์„ ํ•˜๋‚˜ํ•˜๋‚˜ ๋ชจ๋‘ ์„ธ๋ถ€์ ์œผ๋กœ ๊ธฐ๋กํ•˜๋ ค ํ–ˆ๋Š”๋ฐ, ์ƒ๊ฐ๋ณด๋‹ค ๊ธ€์ด ๊ธธ์–ด์ง€๊ธฐ๋„ ํ•˜๊ณ  ์ฒ˜์Œ๋ถ€ํ„ฐ ์ฝ์–ด๋ณด๋‹ˆ ์ „์ฒด์ ์œผ๋กœ ๋‘์„œ๊ฐ€ ์—†๋Š” ๋Š๋‚Œ์ด ๊ฐ•ํ•ด 2์ฃผ์ฐจ๋ถ€ํ„ฐ๋Š” ํšŒ๊ณ ๋„ ํšŒ๊ณ ์ง€๋งŒ ๋ฏธ์…˜์— ์˜จ์ „ํžˆ ๋”์šฑ ์ง‘์ค‘ํ•˜๋ฉฐ ํšŒ๊ณ ๋ก์€ ๊ตต์ง๊ตต์งํ•œ ๋ฆฌํŽ™ํ† ๋ง์ด๋‚˜ ์‚ฌ๊ณ ๊ณผ์ •์—์„œ ๊นจ๋‹ฌ์€ ๊ฒƒ๋“ค ์œ„์ฃผ๋กœ ์ž‘์„ฑํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.


๋ฏธ์…˜์— ๊ด€ํ•œ ์ œ ์ฝ”๋“œ๋Š” ์•„๋ž˜ ๋งํฌ์—์„œ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
 

 

GitHub - Dongwoongkim/java-baseball-6

Contribute to Dongwoongkim/java-baseball-6 development by creating an account on GitHub.

github.com



<์ด๋ฒˆ ๋ฏธ์…˜์„ ์ฐธ์—ฌํ•˜๋ฉด์„œ ๋„์›€์ด ๋˜์—ˆ๋˜ ์ฐธ๊ณ  ์ž๋ฃŒ>

 

2023.10.16 - [๐Ÿ“• Spring/Java] - [Java] ๊ฐ์ฒด์ง€ํ–ฅ ์ƒํ™œ์ฒด์กฐ ์›์น™ 9๊ฐ€์ง€์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž

 

[Java] ๊ฐ์ฒด์ง€ํ–ฅ ์ƒํ™œ์ฒด์กฐ ์›์น™ 9๊ฐ€์ง€์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž

๊ฐ์ฒด์ง€ํ–ฅ ์ƒํ™œ์ฒด์กฐ 9๊ฐ€์ง€ ์›์น™ ์ฑ… ์†ŒํŠธ์›์Šค ์•ค์†”๋Ÿฌ์ง€์— ๋‚˜์˜ค๋Š” '๊ฐ์ฒด์ง€ํ–ฅ ์ƒํ™œ์ฒด์กฐ ์›์น™'์— ๋Œ€ํ•ด ์•Œ์•„๋ด…์‹œ๋‹ค. ๋ˆ„๊ตฌ๋‚˜ ๊ฐ์ฒด์ง€ํ–ฅ ์„ค๊ณ„๋ฅผ ์ž˜ํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ๋ฌด์˜์‹์ ์œผ๋กœ ๋ฒ„๋ฆฌ๊ธฐ ํž˜

rlaehddnd0422.tistory.com

https://www.youtube.com/watch?v=ogaXW6KPc8I

 

[IntelliJ] ์ฝ”๋“œ ์Šคํƒ€์ผ์„ ์„ค์ •ํ•ด๋ณด์ž (feat.์šฐํ…Œ์ฝ”)

์˜ค๋Š˜๋ถ€ํ„ฐ ์‹œ์ž‘ํ•œ ์šฐ์•„ํ•œ ํ…Œํฌ์ฝ”์Šค 6๊ธฐ์˜ ํ”„๋ฆฌ์ฝ”์Šค๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ฉด์„œ๊ธฐ๋Šฅ ๊ตฌํ˜„์— ์ง‘์ค‘ํ•˜๋Š๋ผ ์ฝ”๋“œ ํฌ๋งท์„ ์ •๋ฆฌํ•˜์ง€ ๋ชปํ•ด, ๊ธฐ๋Šฅ ๊ตฌํ˜„ ์ดํ›„ Commit ์ง์ „์ผ์ผํžˆ ๊ฐ์ฒด๋ฅผ ์ฐพ์•„๋‹ค๋‹ˆ๋ฉฐ Command + Option + L (์ฝ”๋“œ

velog.io

 

Google Java Style Guide ์ •๋ฆฌ

Google Java Style Guide๋Š” Java๋ฅผ ์ž‘์„ฑํ• ๋•Œ ์–ด๋–ค ์Šคํƒ€์ผ๋กœ ์ž‘์„ฑํ•˜๋ฉด ์ข‹์„์ง€์— ๋Œ€ํ•ด ์ž‘์„ฑํ•ด๋†“์€๋ฌธ์„œ์ž…๋‹ˆ๋‹ค. ์™œ ์ด๋Ÿฐ ๋ฌธ์„œ๋ฅผ ๋งŒ๋“ค์–ด ๋†“์•˜์„๊นŒ์š”? ์ œ ์ƒ๊ฐ์€ ์ฝ”๋“œ๋ฅผ ๋ณด๋Š”๋ฐ ํŽธ์•ˆํ•ด์ง€๋ฉฐ ์ด๋กœ ์ธํ•ด ๋‹ค๋ฅธ ์‚ฌ

js1130.tistory.com

 

MVC ํŒจํ„ด , 5 Layer ํŒจํ„ด

์œ ํŠœ๋ธŒ ์šฐ์•„ํ•œ Tech ์ฑ„๋„์—์„œ 10๋ถ„ ํ…Œ์ฝ”ํ†ก์„ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. ๋ชฉ์ฐจ MVC ํŒจํ„ด์ด๋ž€, Model, View, Controller Service Layer MVC๋ฅผ ์ง€ํ‚ค๋ฉด์„œ ์ฝ”๋”ฉํ•˜๋Š” ๋ฐฉ๋ฒ• 5 Layer References MVC ํŒจํ„ด์ด๋ž€ * ์ถœ์ฒ˜ : ์œ„ํ‚คํ”ผ๋””์•„

0soo.tistory.com

 

๋ธ”๋กœ๊ทธ์˜ ์ •๋ณด

Study Repository

rlaehddnd0422

ํ™œ๋™ํ•˜๊ธฐ