vendredi 23 octobre 2015

Solving cyclic dependencies in java

I have three classes, say, A,B and C. The basic idea is, the class A passes a message to B and waits, based on that message B passes a message to C. Finally, after C processes the message, it informs A to continue with it's function. Now this forms circle. To reduce the dependencies, I make class A to communicate with B through C, i.e. C has a method that passes the message of A to B. The problem with this approach is that it exposes the interface of B to A, which I dont want to happen. my questions is, what is the best way to approach this problem.

To give more context, I am working on a speech recognition system. I started with 2 classes, one to get the recognition results (A) another to process the result. Later on I had to break the class that processes the result to two, one to do some pre processing (B), like checking how good the result is, and another to process the result (C)

Aucun commentaire:

Enregistrer un commentaire