๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Today I Learned(TIL)/์ŠคํŒŒ๋ฅดํƒ€ ๋‚ด์ผ๋ฐฐ์›€์บ ํ”„

์ฃผํŠน๊ธฐ ์ž…๋ฌธ/์ˆ™๋ จ_Day 8

by carrot0911 2024. 12. 6.

์˜ค๋Š˜ ํ•œ ๊ณต๋ถ€ ๐Ÿง 

  • ๋ฒ ์ด์ง๋ฐ˜ 1ํšŒ์ฐจ ๋…นํ™”๋ณธ ๋ณด๊ธฐ
  • ๊ฐœ์ธ ๊ณผ์ œ Lv1, Lv2 ๋„์ „
  • TIL ๋ธ”๋กœ๊ทธ ์ž‘์„ฑ

 

์˜ค๋Š˜ ์–ป์€ ๋‚ด์šฉ ์ •๋ฆฌ โœ๏ธ 

์˜ค๋Š˜ ์ง„ํ–‰ํ–ˆ๋˜ ๊ณผ์ œ ์ง„ํ–‰ ์ƒํ™ฉ์„ ์ •๋ฆฌํ•ด ๋†”์•ผ๊ฒ ๋‹ค!

  1. ๋จผ์ € project์™€ GitHub ๋ ˆํผ์ง€ํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ค๊ณ  ์—ฐ๋™ํ–ˆ๋‹ค.
  2. ๊ทธ๋‹ค์Œ controller, service, repository, domain, dto ํŒจํ‚ค์ง€๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค.
  3. ๊ฐ๊ฐ์„ ์ผ์ •์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋„๋ก domain ํŒจํ‚ค์ง€์— Todo ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ํ•„๋“œ์™€ ์ƒ์„ฑ์ž๋ฅผ ์ž‘์„ฑํ–ˆ๋‹ค.
  4. ์ •๋ณด๋“ค์„ ์ „๋‹ฌํ•ด ์ค„ ์ˆ˜ ์žˆ๋Š” TodoRequestDto์™€ TodoResponseDto ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค.
  5. TodoService ์ธํ„ฐํŽ˜์ด์Šค์™€ ๊ตฌํ˜„์ฒด TodoScheduleService ํด๋ž˜์Šค, TodoRepository ์ธํ„ฐํŽ˜์ด์Šค์™€ ToroScheduleRepository ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค. TodoScheduleController ํด๋ž˜์Šค๋„ ํ•จ๊ป˜ ์ƒ์„ฑํ•ด ์ฃผ์—ˆ๋‹ค.
  6. ๊ทธ ํ›„ ์ผ์ •์„ ์ƒ์„ฑํ•˜๋Š” ๋ถ€๋ถ„๋ถ€ํ„ฐ ์ง„ํ–‰ํ•˜๋ ค๊ณ  ํ–ˆ์œผ๋‚˜.. ๋ฌด์Šจ ์ผ์ธ์ง€ ์ž๊พธ Import ํ•˜๋Š” ๊ณผ์ •์—์„œ ์œ„์ชฝ์— import ๋˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ, ๊ทธ ์ค„์—์„œ import ๋˜๋Š” ํ˜„์ƒ์ด ๋ฐœ์ƒํ–ˆ๋‹ค.
    ๊ตฌ๊ธ€๋ง๊ณผ chatGPT, ํŠœํ„ฐ๋‹˜์˜ ๋„์›€์„ ๋ฐ›์•„ ์šฐ์„  ์„ธํŒ…์„ ๋ณ€๊ฒฝํ•˜๊ณ , ์บ์‹œ๋„ ์‚ญ์ œํ•ด ๋ณด๊ณ  IntelliJ๋ฅผ ๊ป๋‹ค๊ฐ€ ๋‹ค์‹œ ์ผœ๋ณด๊ธฐ๋„ ํ–ˆ๋Š”๋ฐ ํ•ด๊ฒฐ๋˜์ง€ ์•Š์•˜๋‹ค...
    ๊ณ„์†ํ•ด์„œ import๋ฅผ ์‹œ๋„ํ•  ๋•Œ๋งˆ๋‹ค IDE error ๋ฉ”์‹œ์ง€๊ฐ€ ์šฐ์ธก ํ•˜๋‹จ์— ๋ฐœ์ƒํ–ˆ๊ณ , ๊ฒฐ๊ตญ ํŠœํ„ฐ๋‹˜๊ป˜์„œ IntelliJ๋ฅผ ์™„์ „ ์‚ญ์ œํ–ˆ๋‹ค๊ฐ€ ๋‹ค์‹œ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ์ด ์–ด๋–ป๊ฒ ๋ƒ๊ณ  ํ•˜์…”์„œ ์‚ญ์ œ ํ›„ ์žฌ์„ค์น˜๋ฅผ ์ง„ํ–‰ํ–ˆ๋‹ค. (ํ”Œ๋Ÿฌ๊ทธ์ธ ์ชฝ์—์„œ ์ž๊พธ ์ถฉ๋Œ(?), ์—๋Ÿฌ(?)๊ฐ€ ๋‚˜๋Š” ๊ฒƒ ๊ฐ™์€ ๋Š๋‚Œ์ด๋ผ๊ณ  ํ•˜์…จ๋‹ค.)
    ์žฌ์„ค์น˜ ํ›„ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ–ˆ๋”๋‹ˆ ๋ฌธ์ œ์—†์ด import๊ฐ€ ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜๊ณ  ์ฒ˜์Œ๋ถ€ํ„ฐ ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ค์‹œ ์‹œ์ž‘ํ–ˆ๋‹ค.
  7. ์ „์— ์ง„ํ–‰ํ•œ ๊ณผ์ •์„ ๋ชจ๋‘ ์ง„ํ–‰ ํ›„ ํŠœํ„ฐ๋‹˜๊ป˜์„œ ๋‚ด๋ถ€์— ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ด์šฉํ•ด์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•œ ํ›„ JDBC๋กœ ๊ต์ฒดํ•˜๋Š” ๋ฐฉํ–ฅ๋„ ๊ดœ์ฐฎ๋‹ค๊ณ  ํ•˜์…”์„œ HashMap์„ ์ƒ์„ฑํ•ด์„œ ์ผ์ • ์ƒ์„ฑ๋ถ€ํ„ฐ ์‹œ์ž‘ํ–ˆ๋‹ค.
  8. ์ผ์ • ์ƒ์„ฑ - TodoScheduleController(createTodoAPI ๋ฉ”์„œ๋“œ), TodoScheduleService(createTodoService ๋ฉ”์„œ๋“œ), TodoScheduleRepository(createTodo ๋ฉ”์„œ๋“œ)
  9. ์ „์ฒด ์ผ์ • ์กฐํšŒ - TodoScheduleController(searchAllTodoAPI ๋ฉ”์„œ๋“œ), TodoScheduleService(searchAllTodoService ๋ฉ”์„œ๋“œ), TodoScheduleRepository(searchAllTodo ๋ฉ”์„œ๋“œ)
  10. ์„ ํƒ ์ผ์ • ์กฐํšŒ - TodoScheduleController(searchTodoById ๋ฉ”์„œ๋“œ), TodoScheduleService(searchTodoByIdService ๋ฉ”์„œ๋“œ), TodoScheduleRepository(searchTodoById ๋ฉ”์„œ๋“œ) → ์ถ”๊ฐ€ ์กฐ๊ฑด์ด ์žˆ์—ˆ์ง€๋งŒ JDBC๋กœ ๊ต์ฒดํ•˜๋Š” ๊ณผ์ •์—์„œ ์ถ”๊ฐ€ํ•˜๊ธฐ๋กœ ํ•˜๊ณ  ์ผ๋‹จ ๊ตฌํ˜„์— ์ง‘์ค‘ํ–ˆ๋‹ค.
  11. ์„ ํƒ ์ผ์ • ์ˆ˜์ • - TodoScheduleController(updateTodoAPI ๋ฉ”์„œ๋“œ), TodoScheduleService(updateTodoService ๋ฉ”์„œ๋“œ), TodoScheduleRepository(์ˆ˜์ •ํ•  ๋•Œ๋Š” ์‚ฌ์šฉํ•  ํ•„์š” ์—†์Œ)
  12. ์„ ํƒ ์ผ์ • ์‚ญ์ œ - TodoScheduleController(deleteTodoAPI ๋ฉ”์„œ๋“œ), TodoScheduleService(deleteTodoService ๋ฉ”์„œ๋“œ), TodoScheduleRepository(deleteTodo ๋ฉ”์„œ๋“œ) 
  13. ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด์„œ ์š”๊ตฌ์‚ฌํ•ญ์— ์žˆ๋Š” ์กฐ๊ฑด์„ ๋งŽ์ด ๋นผ๋จน์–ด์„œ JDBC๋กœ ๋ฐ”๊พธ๋Š” ๊ณผ์ •์—์„œ ๋‹ค ์ฑ„์›Œ ๋„ฃ์„ ์˜ˆ์ •์ด๋‹ค.

 

์˜ค๋Š˜ ํ•˜๋ฃจ ์ •๋ฆฌ โœ๏ธ

IntelliJ ์—๋Ÿฌ ๋•Œ๋ฌธ์— ์˜ค์ „๊ณผ ์˜คํ›„์˜ ์‹œ๊ฐ„์„ ๋‚ ๋ ค๋ฒ„๋ ธ๋‹ค..
Import๋„ ์ œ๋Œ€๋กœ ๋˜์ง€ ์•Š๊ณ , ๊ณ„์†ํ•ด์„œ IDE error๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์„ ๋ด์„œ๋Š” ์„ค์น˜ํ•  ๋•Œ์˜ ๋ฌธ์ œ์ด๊ฑฐ๋‚˜ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์„ค์น˜ํ•  ๋•Œ ๋ญ˜ ์ž˜๋ชป ๊ฑด๋“œ๋ ธ์„ ํ™•๋ฅ ์ด ๋†’์„ ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค..

๊ทธ๋ž˜๋„ ์˜ค๋Š˜ ๊ณผ์ œ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ ์Šคํ”„๋ง์˜ ํ๋ฆ„์— ๋Œ€ํ•ด ์กฐ๊ธˆ์€ ๊ฐ์„ ์žก์€ ๋Š๋‚Œ์ด๋‹ค.
์˜ค์ „์— ๋“ค์€ ๋ฒ ์ด์ง๋ฐ˜ ๋…นํ™” ์˜์ƒ์ด ๋„์›€์ด ๋งŽ์ด ๋˜์–ด์„œ 3 Layer Architecture๋ฅผ ์ƒ๊ฐํ•˜๋ฉด์„œ ๊ณผ์ œ๋ฅผ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ๊ฐ•์˜๋ฅผ ๋ณด๋ฉด์„œ ์‹ค์Šตํ–ˆ๋˜ ์ฝ”๋“œ๋“ค์„ ๋ณด๋ฉด์„œ ๊ณผ์ œ๋ฅผ ์ง„ํ–‰ํ–ˆ๋Š”๋ฐ ๋ณต์Šตํ•˜๋Š” ๋Š๋‚Œ๋„ ๋“ค์—ˆ๊ณ  ๋จธ๋ฆฌ์—์„œ ์กฐ๊ธˆ์”ฉ ์ •๋ฆฌ๊ฐ€ ๋๋‹ค.

๊ทผ๋ฐ ์•„์ง ์š”๊ตฌ์‚ฌํ•ญ์„ ๋‹ค ์ ์šฉํ•˜์ง€๋„ ๋ชปํ–ˆ๊ณ .. JDBC๋ฅผ ์‘์šฉํ•ด์„œ ๋ฐ”๊ฟ”์•ผ ํ•˜๊ณ .. ํ•  ๊ฒƒ์ด ๋งŽ๋‹ค!!!
์˜ค๋Š˜์ด ๊ธˆ์š”์ผ์ด์ง€๋งŒ ์ฃผ๋ง์—๋„ ๊ณผ์ œ์— ์˜ฌ์ธํ•ด์„œ ์ตœ๋Œ€ํ•œ ์ง„๋„๋ฅผ ๋งŽ์ด ๋‚˜๊ฐ€์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค! ํ™”์š”์ผ ์ „์—๋Š” ๋ฌด์กฐ๊ฑด ์™„์„ฑํ•œ๋‹ค๋Š” ์ƒ๊ฐ์œผ๋กœ ์ง„ํ–‰ํ•ด์•ผ์ง€ ๐Ÿ˜Ž๐Ÿคจ 

์ด๋ฒˆ ์ฃผ๋Š” ์Šคํ”„๋ง ๋•Œ๋ฌธ์— ๊ณ ์ƒ์ด ๋งŽ์•˜์ง€๋งŒ ๊ทธ๋ž˜๋„ ๋‚˜๋ฆ„ ์„ฑ์žฅํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ ๊ฐ™์•„์„œ ๋‹คํ–‰์ด๋‹ค.. ๊ณ„์† ์„ฑ์žฅํ•ด ๋‚˜๊ฐ€์ž!!
์ฃผ๋ง๋„ ํŒŒ์ดํŒ…!!

 

๋‚ด์ผ ๊ณ„ํš โฐ

  • ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ(Java, SQL) 1๋ฌธ์ œ ํ’€์ด & ๋ธ”๋กœ๊ทธ ์ •๋ฆฌ
  • ๊ณผ์ œ Lv1, Lv2 ์ˆ˜์ • - JDBC ์ˆ˜์ •๊นŒ์ง€ ๋ชฉํ‘œ!