Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Interface-based framework?

I was going through Effective Java and reading static factory methods for creating objects. Its chapter 2, Item 1. There in the advantage no. 3, the writer has mentioned like

Hiding implementation classes in this fashion can lead to a very compact API. This technique lends itself to interface-based frameworks, where interfaces provide natural return types for static factory methods.

I could not understand what the interface-based frameworks are?

like image 716
darkapple Avatar asked Apr 28 '11 10:04

darkapple


1 Answers

Maybe rephrasing it a bit would help :

an interface-based framework is a framework giving the user/client lib access to interfaces only while actually delivering classes implementing those interfaces.

The benefit of this approach consists in giving the implementor full control over the implementation and giving the client a stable API at the same time.

I encountered an example lately, where the client gets an XmlProcessor from an API method. Inside the framework, there are three totally different implementation of this processor : a DomXmlProcessor, SaxXmlProcessor and a VtdXmlProcessor. The details of the individual implementations are of no concern to the client and can be switched any time.

like image 163
kostja Avatar answered Oct 11 '22 10:10

kostja