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
  • PrintPrint
Share this Page URL
Help

Designing to Interfaces

Designing to interfaces is a common practice when architecting and implementing an application, no matter which framework or standard (Spring, JBoss Seam, Guice, EJB, and so on) you are working on. One of the main design goals of Spring is to further ease the development of applications that are designed and implemented around a set of well-defined interfaces. Before we can look at designing a Spring-based application in any detail, we should explore exactly why designing to interfaces is such a big thing and how Spring goes about making it easier.

Why Design to Interfaces

There are many reasons you should design and code your applications to interfaces rather than to a concrete class hierarchy, but perhaps the biggest reason is to reduce coupling. If components in your application communicate with each other in terms of interfaces rather than concrete types, it becomes very easy to swap out a component if it becomes problematic. This capability allows you to switch from one implementation to another, without having to touch the rest of the application code; indeed, it is possible for your application to work with many different implementations of the same interface without even being aware that it is doing so. For example, when using profile support in Spring, you can provide different concrete implementati....


  

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
  • PrintPrint