์›๋ณธ๊ฐ’์„ ์•ˆ์ „ํ•˜๊ฒŒ ๋ณดํ˜ธํ•˜์ž by unmodifiableList & Deep Copy & VO

์›๋ณธ์ฝ”๋“œ ๊ฐ’ ๋ณ€ํ™” ์‹คํ—˜ : Java) Shallow Copy vs Deep Copy (์–•์€/๊นŠ์€ ๋ณต์‚ฌ), unmodifiableList์˜ ๊ฐ’ ๋ณ€ํ™” ๊ด€์ฐฐ ์ขŒํ‘œ๊ณ„์‚ฐ๊ธฐ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋‹ค๊ฐ€, Jason์ฝ”์น˜๋‹˜์˜ ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ›๊ณ  ์›๋ณธ๊ฐ’์„ ์•ˆ์ „ํ•˜๊ฒŒ ๋ณดํ˜ธํ•˜๊ธฐ ์œ„ํ•ด 3๊ฐ€์ง€ ๋ฐฉ๋ฒ•์„ ์ ์šฉํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. (์„ธ ๊ธฐ๋ฒ•์ด ๋ชจ๋‘ ๊ฐ์ž์˜ ๊ด€์ ์ด ๋‹ค๋ฅด๊ธด ํ•˜์ง€๋งŒ, ์ผ๋‹จ์€) Collections.unmodifiableList Deep Copy VO(Value Object) ์‚ฌ์ „์ง€์‹ : final์€ ์žฌํ• ๋‹น๋งŒ ๋ง‰์ง€, ๊ฐ’ ์กฐ์ž‘์€ ๋ง‰์ง€๋ชปํ•œ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์€ ์ปจํŠธ๋กค๋Ÿฌ ์ฝ”๋“œ๊ฐ€ ์žˆ๋‹ค. ์›๋ณธ๊ฐ’์ธ List๋ฅผ ๋ฐ›์•„๋“ค์ด๊ณ , ์ด๋ฅผ ์กฐ์ž‘ํ•ด์„œ figure๋ฅผ ๋งŒ๋“ค๊ณ  ์ถœ๋ ฅํ•œ๋‹ค. List๋ฅผ ๊ฐ–๊ณ ์žˆ๋Š” ๋„๋ฉ”์ธ ๋ชจ๋ธ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. ์ „ํ˜•์ ์ธ ์ƒ์„ฑ์ž์™€ ์ „ํ˜•์ ์ธ getter. ๋‹จ์ˆœํžˆ ..

General, Java 2019. 9. 14. 15:02
์šฉ์–ด์ •๋ฆฌ - DTO vs VO / DAO / POJO

DTO vs VO (Data Transfer Object / Value Object) ์šฉ๋„๋Š” ๋น„์Šทํ•˜๋‚˜, ๊ฐ„๋‹จํžˆ DTO๋Š” variable / VO๋Š” value ๊ฐ™์€ ๋Š๋‚Œ ๋˜๋‹ค๋ฅธ ํ‘œํ˜„์œผ๋กœ๋Š”, DTO๋Š” Instance / VO๋Š” Literal ๊ฐ™์€ ๋Š๋‚Œ (๋Š๋‚Œ๋งŒ!) DTOVOData Transfer ObjectValue Objectํ”„๋กœ์„ธ์Šค๊ฐ„ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๊ฐ์ฒด๊ฐ„๋‹จํ•œ ๋…๋ฆฝ์ฒด(Entity)๋ฅผ ์˜๋ฏธํ•˜๋Š” ์ž‘์€ ๊ฐ์ฒด์‚ฌ์‹ค์ƒ ์šฉ๋„๋Š” ๋‘˜๋‹ค ๋„๋ฉ”์ธ๋‹จ์œ„์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ๋น„์Šทํ•œ ์šฉ๋„์ƒํƒœ ๋ณ€๊ฒฝ ๊ฐ€๋ŠฅRead-Only : ํ•œ๋ฒˆ ๊ฐ’์„ ์ดˆ๊ธฐํ™”ํ•˜๋ฉด ๋ณ€๊ฒฝ๋ถˆ๊ฐ€Business logic๊นŒ์ง€ ๋‹ด์•„์„œ ์‚ฌ์šฉํ•˜๊ธฐ๋„.equals()๋กœ ๋น„๊ตํ• ๋•Œ, ๋ชจ๋“  ๊ฐ’์„ ๋น„๊ตํ•ด์•ผํ•œ๋‹คex) ๋ณดํ†ต "CarDto"์™€ ๊ฐ™์ด ํด๋ž˜์Šค์ด๋ฆ„์— ์ ‘๋ฏธ์‚ฌ๋กœ ์šฉ๋„๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค ์ตœ๋Œ€ํ•œ ..

General, Java 2019. 9. 14. 14:31
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
๊ธ€ ๋ณด๊ด€ํ•จ