Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Because cyclic dependencies are so bad, we need to remove the cyclic dependency between the bill.jar and audit.jar modules. To do this, we’ll apply the Acyclic Relationships pattern, which states that module relationships must be acyclic. We’ll introduce an additional abstraction, called Auditable, that our Bill class implements. Upon applying this little trick, we can see that we have now removed the bidirectional relationship between Bill and the AuditFacade interface, as shown in Figure 7.5.
Figure 7.5. Acyclic relationships between classes
Acyclic Relationships pattern, 146
Whereas previously the AuditFacade accepted a Bill to the audit method, it now accepts an Auditable type. The new AuditFacade interface can be seen in the code snippet shown in Listing 7.6.