๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

Observer pattern vs Pub-Sub pattern

Observer vs Pub-Sub Pattern

์˜ต์ €๋ฒ„ ํŒจํ„ด#

2020-10-30-observer-pattern-vs-pub-sub-pattern-image-0

Pub-Sub ํŒจํ„ด#

2020-10-30-observer-pattern-vs-pub-sub-pattern-image-1

์ฐจ์ด์ #

2020-10-30-observer-pattern-vs-pub-sub-pattern-image-2

  • Observer ํŒจํ„ด์—์„œ Observer๋Š” Subject๋ฅผ ์•Œ๊ณ  ์žˆ๊ณ , Subject๋Š” Observer์— ๋Œ€ํ•œ ๊ธฐ๋ก์„ ์œ ์ง€ํ•œ๋‹ค. ๋ฐ˜๋ฉด Pub-Sub ํŒจํ„ด์—์„œ Publisher์™€ Subscriber๋Š” ์„œ๋กœ๋ฅผ ์•Œ ํ•„์š”๊ฐ€์—†๋‹ค. ๋‹จ์ˆœํžˆ ๋ฉ”์‹œ์ง€ ๋ฒ„์Šค๋‚˜, ๋ธŒ๋กœ์ปค์˜ ๋„์›€์œผ๋กœ ํ†ต์‹ ํ•œ๋‹ค.

  • Observer ํŒจํ„ด๋ณด๋‹ค Pub-Sub ํŒจํ„ด์ด ์„œ๋กœ ๋Š์Šจํ•˜๊ฒŒ ๊ฒฐํ•ฉ๋˜์–ด ์žˆ๋‹ค.

  • Observer ํŒจํ„ด์€ ๋Œ€๋ถ€๋ถ„ ๋™๊ธฐ์ ์œผ๋กœ ๊ตฌํ˜„๋œ๋‹ค. (์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•  ๋•Œ ๊ด€์ฐฐ์ž์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ์‹คํ–‰) Pub-Sub ํŒจํ„ด์€ ๋Œ€๋ถ€๋ถ„ ๋น„๋™๊ธฐ์ ์œผ๋กœ ๊ตฌํ˜„๋œ๋‹ค. (๋ฉ”์‹œ์ง€ ํ๋ฅผ ์‚ฌ์šฉ)