<<< interface constants example | Index | Cloneable interface example >>> |
The ProductAccessFactory class insulates interface from the implementation.
public class ProductAccessFactory { public static ProductAccess getProductAccess() { ProductAccess pa = new ProductAccessImplementation(); return pa; } }//class ProductAccessFactory
The benefit of separating interface from implementation is that the implementation becomes replaceable: it can be swapped with another implementation by changing a single line of code in the ProductAccessFactory class.
<<< interface constants example | Index | Cloneable interface example >>> |