Does B need to know about all possible A's or just the one that called it (the one it tells "I am Done")? If so, then A can have the list of All B's, and B can have a reference to only the one A that matters.

Here's how I'd do it. Yes there's a cyclic association, but there's some control in how it's used. And this can eventually be refactored to a purer observer pattern if required.

An event is only a good answer if he has that abstraction in a library or the language itself. The question makes no assumption about language so even though you used C# it's still a good answer.
–
Samuel DanielsonSep 8 '09 at 19:04

At this moment, B only needs to know the one who calls it -- because only A have the list of B and only A know which one to call next. I think this is the natural solution now. That's also what came to my mine when I met this problem. ---- Maybe use some abstract class for A and B will make it cleaner.
–
lilyonwindSep 8 '09 at 19:06

I am using python, so event is not choice. BTW : event is also an implementation of observer pattern, at least in C#
–
lilyonwindSep 8 '09 at 19:07

1

And one thing makes me skeptic to observer pattern (and event) is that it makes a lot of cylic reference. For example, when I need to drop A, I have to first go over list of B and remove all their reference to A. I think C# now support weak reference when make event binding, but when I worked with C#, I have to remove all these cylce references by hand.
–
lilyonwindSep 8 '09 at 19:10

Thanks, I've been working in C# for the past few months so I had forgotten that not all languages support events. Observer is useful when you need it. In this case, you don't need it, so why have the extra complexity?
–
chocojoshSep 8 '09 at 20:30