Factory and FactoryMethod design pattern implementation