I have a collection of instances of class A. At some point an instance of A realizes that it should delete itself. I want to inform the collection of this, but I do not want A to know anything about the collection.
What is the best way to go about this? It seems to me like A knowing about the collection is very bad coupling, but if I am wrong let me know. Right now I'm thinking of using something like, an instance of A can fire an event, to which the collection is listening. Then when the event is caught by the collection, remove the instance that fired it.
Any ideas on this would be helpful, thanks