|What you are dealing with is called reaction programming .. your object needs to react to things .. anything from collisions to just communicating when asked.
It's well described here along with the usual 3 ways to deal with it
Reactive programming - Wikipedia[^]
Now take care Object-oriented Reactive Programming is not Reactive Object-oriented Programming there is a big difference between those two you need to decide which you are doing and the difference between them.
From what you said I think what you are after is
Observer pattern - Wikipedia[^]
The Observer pattern addresses the following problems:
- A one-to-many dependency between objects should be defined without making the objects tightly coupled.
- It should be ensured that when one object changes state an open-ended number of dependent objects are updated automatically.
- It should be possible that one object can notify an open-ended number of other objects.
Now in programmer jargon speak we call observer pattern programming as "Omnipotent god programming" because there will exist an object or function that observes and controls everything. It is often used in games programming but it is not well suited to real world situations where you can't encapsulate all options and you need to "think" about what is going on.
As an example DNS attacks on websites work because they break the observer pattern of the internet standards .. to deal with the attack you need to know past history and apply some logic
In vino veritas
modified 20-Jan-19 1:05am.