Skip to main content

Posts

Showing posts from July, 2014

Factory Design Pattern - Java

Factory Design Pattern Factory Design Pattern works as per it's name. As one Factory can generate various types of items but of a specific category. Like, Car Factory ( Nissan Car Factory ) can create cars like, Micra, Sunny, Evalia but it can't create Duster. Because,Duster can be created by Renault Car Factory. So, with the same concept, A company can create a various types of Employees. Like, Developer, Admin , Developer Manager. But, only Developer can be Dev Manager. Here is the Complete example of creating the Company with all the Employee details. Class Company.java /** * Parent Class of all Class. Employee is Base class of all types of Employee. * * @author Hari * */ abstract class Employee { public abstract void getMyDetails(); } /** * Admin is child class of the Employee class. * * @author Hari */ class Admin extends Employee { public void getMyDetails() { System.out.println("I'm admin"); } } /** * Develo...