Skip to main content

Posts

Showing posts from April, 2009

Design Patterns

Factory pattern comes into creational design pattern category, the main objective of the creational pattern is to instantiate an object and in Factory Pattern an interface is responsible for creating the object but the sub classes decides which class to instantiate. It is like the interface instantiate the appropriate sub-class depending upon the data passed. Here in this article we will understand how we can create an Factory Pattern in Java. Suppose here i am giving a good and easy example.. ICommunicator is the core interface public interface ICommunicator { public ICommunicator getCommunicator(); public void sayCommunicatorName(); } public interface IRelianceCommunicator extends ICommunicator{ } public interface INokiaCommunicator extends ICommunicator{ } The concrete class NokiaCommunicator and RelianceCommunicator is below import org.apache.log4j.Logger; public class NokiaCommunicator implements INokiaCommunicator { public static final Logger log