First of all, I'm not sure if the title accurately describes what I'm referring to, so feel free to leave a comment on what to call this, or just rename if yourself if you have the rep.
Let's say for example I have 2 classes, Book and Library. A Library contains a property that is a list of all the Books it owns. A Book has a property that that is a list of all the Libraries it belongs to.
On Book I have a RemoveFromLibrary method that removes a library from it's list of libraries. I also want that same method to clean up the other end, namely the library's list of Books that it owns. The same goes for the other end, a RemoveBook method on Library that also cleans up that Book's list of libraries that contain it.
First of all, does this make sense? It seems convenient to me for calling code to not have to worry about cleanup and not have to call 2 methods to perform one logical action. I mean it doesn't make sense to ever remove from one list but not the other. At the same time, it could be said that this makes them too tightly coupled, but I'm thinking I'll just refactor to decouple if it becomes a problem.
What I'm not sure about as far as implementing this is if I just call the normal public method, then I'll end up with an infinite loop of each method calling the other. I could make a separate internal property (working in C#) that doesn't cleanup, but it feels like I'm littering the API with a method that's only meant to be called from one other method. Alternatively I could expose the underlying collection as internal, which is a little better, but it still doesn't seem ideal. Is there a better solution or will I just have to go with one of those two, or make sure calling code does the cleanup itself?