DEV Community

Cover image for Observer Design Pattern O'zbek tilida
Ismoil Turdaliyev
Ismoil Turdaliyev

Posted on

Observer Design Pattern O'zbek tilida

Bir obyektning holati o‘zgarganda, unga obuna bo‘lgan boshqa obyektlarni avtomatik ravishda xabardor qilishni ta’minlaydigan dizayn modeli. Bu pattern publish-subscribe modeliga asoslangan bo‘lib, bir nechta obyektlarning o‘zaro bog‘liqligini boshqarishda ishlatiladi.

Hayotiy taqqoslash
Malika bozorda bir mijoz bor va u mijoz Iphoneni yangi rusumi kelishi bilan xarid qiladi. Kechagina Iphone 17 ni ko'rdi va dokonga bordi. Keldimi shu rusumi deyishsa yo'q hali kelmadi deyishdi. 1 haftadan keyin, 2 haftadan keyin, 3 haftadan keyin yana yana yana kelaverib keldimi shu rusumidan deyaveradi. Yaxshi yechimi mijozni nomerini olib qolib Iphone kelganida unga telefon qilish

  • Publisher - sotuvchi (yangi telefon kelsa habardor qiladigan inson)
  • Subscribers - mijoz (sotuvchidan yangilik kutib o'tiradigan Kit)

Observer Patternning asosiy komponentlari

  1. Subject: Kuzatiladigan obyekt (masalan, yangiliklar kanali).
  2. Observers: Subject’ning holatlarini kuzatib boradigan obyektlar (masalan, obunachilar).
  3. Xabarnoma mexanizmi: Subject va Observers o‘rtasidagi o‘zaro aloqa.

Buyerda esa code:

Image description

Happy coding

Observer #design #pattern #Ismoil #Turdaliyev

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay