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.10. Seventh Refactoring

7.10. Seventh Refactoring

The problem of creating instances is common, so the solution is relatively easy. There are many different ways to do this, but we take the easiest route (and not the most flexible, mind you) by creating an AuditFacadeFactory class. This refactoring is an example of the Implementation Factory pattern, which states that we should use factories to create a modules implementation classes. Now, instead of the AuditAction creating the AuditFacade implementation, it invokes the factory and is returned an instance, as shown in Listing 7.9. An alternative, and possibly a better solution, would have been to inject the appropriate AuditFacade implementation into the AuditFacade using a dependency injection framework, such as Spring.


  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint