Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

7. Reference Implementation > 7.6. Third Refactoring

7.6. Third Refactoring

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.

Image

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial