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 7799679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:23:26+00:00 2026-06-02T00:23:26+00:00

Consider the following general program structure: Class A has an instance of Class B

  • 0

Consider the following general program structure:

  • Class A has an instance of Class B as a member variable
  • Class B has a collection member variable containing instances of class C
  • Events in class A are propagated to the C instances by A simply telling B about the event

What are the design patterns concerning instances of class C talking back to class A?

One option is instances of class C posting notifications to which class A subscribes. Another option is passing a reference to class A “down the chain” (from A to B then from B to each C). This latter option allows instances of C to talk directly to A.

  • 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-06-02T00:23:27+00:00Added an answer on June 2, 2026 at 12:23 am

    If you mean design patterns literally (i.e. of the GoF variety) then these would be a few relevant options:

    • Command: pass a callback to the C items (directly or indirectly through B) so that when they want to talk back to A they can simply invoke this callback — which can even have parameters
    • Iterator: B exposes a view of its aggregate collection directly to A; communication between A and C is then made directly
    • Mediator: Exposes notifications to which A and C might subscribe to; communication is done by posting events
    • Observer: What you already suggested as the first option

    If on the other hand you really mean architectural patterns, then typical options are:

    • Your first option, A subscribing to C events. At first sight this doesn’t look like an all-around good idea unless the event is extremely useful all the time, because it requires n objects to aggregate a pointer back to the callback which in the worst case they could even use just once.
    • Passing references to A is another option, but not a good one if you are going to pollute the public interface of A with methods just so that C can call back to it in very specific scenarios. It can be very effective if A already exposes a suitable interface, but be aware that you might need an adapter class between C calling back to A in order to not tightly couple C to A‘s interface.
    • A third option would be A iterating over (a view of) the collection provided by B directly and supplying callbacks to C instances; this has the advantages of being quite loosely coupled and that it will use the least amount of memory, but it might be a bit trickier to code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following C# code: class Program { static public void Print(string toPrint) {
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
Consider following program: static void Main (string[] args) { int i; uint ui; i
Consider the following code snipet: public class A { private final Executor executor =
Consider the following two Java classes: a.) class Test { void foo(Object foobar) {
Consider the following Grails URL mapping: class UrlMappings { static mappings = { /something/${foo_id}/
Consider the following general issue before I go to the specific problem: You use
Consider the following : class A { public: int xx; A(const A& other) {
Problem Consider the following class template <typename T> struct A { T x; };
Consider following scenario: I have RESTful URL /articles that returns list of articles user

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.