Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:34:49+00:00 2026-05-31T16:34:49+00:00

Observer pattern: There are 2 variants of it. Where Subjects informs all the observers

  • 0

Observer pattern:
There are 2 variants of it.

  1. Where Subjects informs all the observers as an when an event occurs
  2. The observer can query the subject, if an event occured or not.

I am thinking of any real-world examples, which are applicable for option 2 ?

I have used option 1, in one of my projects where there is any particular event (on my socket), all the observers which are registered for that event, gets notified.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:34:51+00:00Added an answer on May 31, 2026 at 4:34 pm

    The second version isn’t an observer at all. That’s simply polling.

    What the Design Patterns book actually described, and what you maybe meant, is this:

    1. Whenever the subject changes, the changed values get pushed to the observer (as arguments to the ‘notify’ call).
    2. Whenever the subject changes, the observer pulls the new state from the subject as needed (no arguments to the ‘notify’ call).

    A use case for the second approach:

    The subject is a set of address book records. Whenever the address book is updated, the observers should be notified. However, the amount of changed data could potentially be rather large and not each of the observers needs all the data. So instead of pushing all the data, you just notify all observers (possibly passing the ‘this’ pointer of the subject as an argument in case the observers should be able to listen to multiple subjects at once) and then provide the new state via getters – that way, each observer can fetch just the information it needs. Like the observer which updates the ‘Number of addresses’ field in your GUI – it’s not interested in the actual names, just in the number of items.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We all know the observer pattern : You have a subject which is able
A Subject-Observer relationship isn't a dependency relationship: Observers don't need Subjects in order to
There is a question already answered which is In C#, isn't the observer pattern
I have observer.h , client.h and field.h files. In observer.h there is Subject class
I have used Observer Pattern for my application. I have a subject which has
I am trying to implement an observer pattern with a template subject class. The
By referring to article Implementing a Subject/Observer pattern with templates template <class T> class
First of all, I know there are excellent implementations (Qt, Boost, cpp-event, etc.), but
I want to implement a generic Observer Pattern for user controls. What is the
Where to find good material to study observer pattern? I need some examples, of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.