๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋นˆ ๊ตฌ๋ฉ ์ฑ„์šฐ๊ธฐ

[OOP] ๊ฐ์ฒด์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์€ ์–ด๋–ป๊ฒŒ ํ˜„์‹ค ์„ธ๊ณ„๋ฅผ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ํ‘œํ˜„ํ•˜๋‚˜

์ถœ์ฒ˜

ChatGPT์—๊ฒŒ ์งˆ๋ฌธํ•จ.

 

๋‚ด์šฉ

  ํ˜„์‹ค ์„ธ๊ณ„ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
๊ฐ์ฒด Object ๊ฐœ๋… ํ˜„์‹ค ์„ธ๊ณ„์—์„œ๋Š” ๋ชจ๋“  ๊ฒƒ์ด ๊ฐ์ฒด๋‹ค.
ํ˜„์‹ค ์„ธ๊ณ„์˜ ๋ชจ๋“  ๊ฒƒ๋“ค์€ ์ƒํƒœ(ํŠน์„ฑ, ์†์„ฑ)๊ณผ ํ–‰๋™(๋ฉ”์„œ๋“œ)๋ฅผ ๊ฐ–๋Š”๋‹ค
ex) ์ž๋™์ฐจ, ์‚ฌ๋žŒ, ๋™๋ฌผ ๋“ฑ๋“ฑ
๊ฐ์ฒด๋ผ๋Š” ๊ฐœ๋…์œผ๋กœ ํ˜„์‹ค ์„ธ๊ณ„์˜ ์‚ฌ๋ฌผ์„ ํ‘œํ˜„ํ•œ๋‹ค.
๊ฐ์ฒด๋Š” ๋ฐ์ดํ„ฐ์™€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ํฌํ•จํ•œ๋‹ค.
ํ˜„์‹ค ์„ธ๊ณ„์˜ ์‚ฌ๋ฌผ๋“ค์ด ์ƒํƒœ(ํŠน์„ฑ)์™€ ํ–‰๋™์„ ๊ฐ–๋Š” ๊ฒƒ๊ณผ ์œ ์‚ฌํ•˜๋‹ค.
์บก์Šํ™”
Encapsulation
๊ฐ์ฒด๋“ค์ด ์ž์‹ ๋งŒ์˜ ๋‚ด๋ถ€ ์ƒํƒœ๋ฅผ ๊ฐ€์ง€๊ณ  ์™ธ๋ถ€์™€ ์ƒํ˜ธ์ž‘์šฉํ•  ๋•Œ ํ•„์š”ํ•œ ์ •๋ณด๋งŒ ์ œ๊ณตํ•œ๋‹ค.
ex) ์ž๋™์ฐจ์˜ ์—”์ง„ ๋‚ด๋ถ€ ๊ตฌ์กฐ๋ฅผ ์•Œ ํ•„์š”์—†์ด ์šด์ „์ž๋Š” ํ•ธ๋“ค๊ณผ ํŽ˜๋‹ฌ๋งŒ์œผ๋กœ ์šด์ „์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.
์บก์Šํ™”๋ฅผ ํ†ตํ•ด ๊ฐ์ฒด ๋‚ด๋ถ€๋ฅผ ์ˆจ๊ธฐ๊ณ , ๊ณต๊ฐœ๋œ ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด์„œ๋งŒ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค. ์ด๋ ‡๊ฒŒ ๊ฐ์ฒด์˜ ๋ฌด๊ฒฐ์„ฑ์„ ์œ ์ง€ํ•˜๊ณ  ๋ณต์žก์„ฑ์„ ์ค„์ด๋Š” ๋ฐ ๋„์›€์„ ์ค€๋‹ค.
์ƒ์†
Inheritance
ํŠน์ • ๊ฐ์ฒด๋“ค์ด ๋‹ค๋ฅธ ๊ฐ์ฒด๋“ค๋กœ๋ถ€ํ„ฐ ์ƒํƒœ์™€ ํ–‰๋™์„ ์ƒ์†๋ฐ›์•„ ๊ณต์œ ํ•œ๋‹ค.
ex) ์ž์ „๊ฑฐ, ์ž๋™์ฐจ, ๋ฒ„์Šค ๋“ฑ์€ ๋ชจ๋‘ 'ํƒˆ ๊ฒƒ'์ด๋ผ๋Š” ๊ณตํ†ต์ ์ธ ํŠน์„ฑ(์ƒํƒœ)์™€ ํ–‰๋™์„ ๊ณต์œ ํ•œ๋‹ค.
์ƒ์†์œผ๋กœ ํด๋ž˜์Šค ๊ฐ„ ๊ด€๊ณ„๋ฅผ ํ‘œํ˜„ํ•˜๊ณ , ์ฝ”๋“œ์˜ ์žฌ์‚ฌ์šฉ์„ฑ์„ ๋†’์ธ๋‹ค. 
์ƒ์†์œผ๋กœ ์ž์‹ ํด๋ž˜์Šค๋Š” ๋ถ€๋ชจ ํด๋ž˜์Šค์˜ ์†์„ฑ๊ณผ ๋ฉ”์„œ๋“œ๋ฅผ ๋ฌผ๋ ค๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.
๋‹คํ˜•์„ฑ
Polymorphism
๊ฐ™์€ ๋™์ž‘์ด๋ผ๋„ ๊ฐ์ฒด์— ๋”ฐ๋ผ ๋‹ค๋ฅด๊ฒŒ ์ˆ˜ํ–‰๋  ์ˆ˜ ์žˆ๋‹ค.
ex) ๊ฐœ์™€ ๊ณ ์–‘์ด๋Š” ๋ชจ๋‘ '๋™๋ฌผ'์— ์†ํ•˜์ง€๋งŒ, ๊ฐ๊ฐ ๋‹ค๋ฅธ ์†Œ๋ฆฌ๋ฅผ ๋‚ธ๋‹ค.
๋‹คํ˜•์„ฑ์„ ํ†ตํ•ด ๊ฐ์ฒด๊ฐ€ ๋™์ผํ•œ ์ธํ„ฐํŽ˜์ด์Šค ๋˜๋Š” ์ƒ์†๋œ ํด๋ž˜์Šค์— ์˜ํ•ด ์ •์˜๋œ ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜์ง€๋งŒ, ์‹ค์ œ๋กœ ์‹คํ–‰๋˜๋Š” ๋ฐฉ๋ฒ•์€ ๊ฐ์ฒด์— ๋”ฐ๋ผ ๋‹ค๋ฅด๊ฒŒ ๊ตฌํ˜„๋  ์ˆ˜ ์žˆ๋‹ค.
์ถ”์ƒํ™”
Abstraction
๋ณต์žกํ•œ ์‹œ์Šคํ…œ์„ ์ดํ•ดํ•˜๊ธฐ ์œ„ํ•ด ์„ธ๋ถ€ ์‚ฌํ•ญ์„ ์ˆจ๊ธฐ๊ณ  ์ค‘์š”ํ•œ ๋ถ€๋ถ„์—๋งŒ ์ง‘์ค‘ํ•œ๋‹ค.
ex) ์ปดํ“จํ„ฐ ์‚ฌ์šฉ ์‹œ ๋ƒ… ํšŒ๋กœ ์ž‘๋™ ๋ฐฉ์‹์€ ์•Œ ํ•„์š”๊ฐ€ ์—†๋‹ค.
๋ณต์žกํ•œ ์‹œ์Šคํ…œ์„ ๋‹จ์ˆœํ™”ํ•ด์„œ ํ•„์š”ํ•œ ๋ถ€๋ถ„๋งŒ ๋…ธ์ถœํ•œ๋‹ค.

 


ChatGPT์—๊ฒŒ ํ•ด๋‹น ๊ธ€์˜ ์ถœ์ฒ˜๋ฅผ ๋ฌผ์—ˆ๋‹ค.

OOP์™€ ํ˜„์‹ค ์„ธ๊ณ„ ํ‘œํ˜„์˜ ์ถœ์ฒ˜

์œ„์˜ ๊ฐœ๋…๋“ค์€ ๋‹ค์–‘ํ•œ ๋ฌธํ—Œ๊ณผ ์—ฐ๊ตฌ์—์„œ OOP๊ฐ€ ํ˜„์‹ค ์„ธ๊ณ„๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ธฐ์ˆ ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ๋ช‡ ๊ฐ€์ง€ ๊ถŒ์œ„ ์žˆ๋Š” ์ถœ์ฒ˜์ž…๋‹ˆ๋‹ค:

  1. "Object-Oriented Analysis and Design with Applications" by Grady Booch
    • Grady Booch๋Š” ๊ฐ์ฒด์ง€ํ–ฅ ๋ถ„์„๊ณผ ์„ค๊ณ„์˜ ์„ ๊ตฌ์ž๋กœ์„œ, ๊ทธ์˜ ์ €์„œ์—์„œ๋Š” ๊ฐ์ฒด์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด ํ˜„์‹ค ์„ธ๊ณ„์˜ ๋ณต์žก์„ฑ์„ ๋ชจ๋ธ๋งํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.
  2. "Object-Oriented Software Construction" by Bertrand Meyer
    • ์ด ์ฑ…์€ OOP์˜ ํ•ต์‹ฌ ์›๋ฆฌ๋ฅผ ์†Œ๊ฐœํ•˜๋ฉฐ, ํŠนํžˆ ์บก์Šํ™”์™€ ๋ชจ๋“ˆํ™”์˜ ์ค‘์š”์„ฑ์„ ๊ฐ•์กฐํ•ฉ๋‹ˆ๋‹ค.
  3. "Design Patterns: Elements of Reusable Object-Oriented Software" by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides
    • ์ด ์ฑ…์€ ๊ฐ์ฒด์ง€ํ–ฅ ์„ค๊ณ„์˜ ์ฃผ์š” ํŒจํ„ด์„ ์„ค๋ช…ํ•˜๋ฉฐ, ํ˜„์‹ค ์„ธ๊ณ„์˜ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋‹ค๋ฃน๋‹ˆ๋‹ค.
  4. "Object-Oriented Modeling and Design" by James Rumbaugh
    • James Rumbaugh๋Š” ๊ฐ์ฒด์ง€ํ–ฅ ๋ชจ๋ธ๋ง์˜ ๊ฐœ๋…์„ ์†Œ๊ฐœํ•˜๋ฉฐ, OOP๊ฐ€ ์–ด๋–ป๊ฒŒ ํ˜„์‹ค ์„ธ๊ณ„์˜ ์‹œ์Šคํ…œ์„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋Š”์ง€๋ฅผ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.
  5. "Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development" by Craig Larman
    • ์ด ์ฑ…์€ UML์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์ฒด์ง€ํ–ฅ ๋ถ„์„๊ณผ ์„ค๊ณ„๋ฅผ ์„ค๋ช…ํ•˜๋ฉฐ, OOP์˜ ๋‹ค์–‘ํ•œ ๊ฐœ๋…์„ ํ†ตํ•ด ํ˜„์‹ค ์„ธ๊ณ„์˜ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ์‹œํ•ฉ๋‹ˆ๋‹ค.
  6. "Object-Oriented Software Engineering: A Use Case Driven Approach" by Ivar Jacobson
    • Ivar Jacobson์€ ๊ฐ์ฒด์ง€ํ–ฅ ์†Œํ”„ํŠธ์›จ์–ด ๊ณตํ•™์˜ ๋ฐฉ๋ฒ•๋ก ์„ ์„ค๋ช…ํ•˜๋ฉฐ, OOP๊ฐ€ ์–ด๋–ป๊ฒŒ ํ˜„์‹ค ์„ธ๊ณ„์˜ ๋ณต์žก์„ฑ์„ ๋‹ค๋ฃจ๋Š”์ง€๋ฅผ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.