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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:14:08+00:00 2026-06-01T13:14:08+00:00

In a game i’m programming, I use a composite object for all entities within

  • 0

In a game i’m programming, I use a composite object for all entities within the game. The entities are made up of component objects which define small chunks of functionality such as health, or movement.

My question is:

Is it ok to post a notification from a component, but reference its parent entity as the object sending the notification instead?

I’m tempted to do this, as it is easier to add observers to the entity, instead of finding the correct component inside the entity.

I’ve been told that you should never post a notification for another object.

What are the pros and cons?

  • 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-01T13:14:10+00:00Added an answer on June 1, 2026 at 1:14 pm

    Usually you think of a notification as coming “from” an object. Therefore, if you’re debugging and you want to find the source of the notification, you look for the code in that object itself.

    It’s not illegal to violate that expectation, but it may make someone curse you a little bit when they have to work harder to find the real source of the notification.

    Also, if you have a lot of separate components that all post the notification, it can get more difficult to refactor the code if you ever want to change the notification (for instance, the userInfo in it).

    If you can guarantee that your component always has a valid pointer to its parent, the best solution is to make the component ask its parent to post the notification:

    @implementation ComponentA
    
    - (void)someMethod
    {
         [self.parent pleasePostSomethingChangedNotification];
    }
    
    @end
    
    @implementation Parent
    
    - (void)pleasePostSomethingChangedNotification
    {
         // Parent may post the notification immediately,
         // or may selectively post the notification based on some other condition,
         // or post it later on after coalescing changes from several components, 
         // or ...
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The game is simple where the Pan object catches the Pizza objects that are
I have a game which I use a flag variable score to keep the
My game is a small shooting game in cocos2d. The enemy generates the bullets
I am programming a game using Visual C++ 2008 Express and the Ogre3D sdk.
This one game I do scripting for uses a primary dll in which our
The game will be written in C++ Programming: enemies.puch_back(new DefaultEnemy(200, 300, 3, 5)); enemies.puch_back(new
I have a simple game that is in progress. As of right now all
My game uses a d = vt calculation for movement of objects where t
I have a game which displays an array of colored blocks. The user can
A game that I play stores all of its data in a .DAT file.

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.