我无法理解工厂方法模式。从此处的示例:http ://worldwardiary.com/history/Factory_method_pattern#Using_the_factory_pattern和此处:https ://stackoverflow.com/a/806942/2420939 :
public class ImageReaderFactory
{
public static ImageReader getImageReader( InputStream is )
{
int imageType = figureOutImageType( is );
switch( imageType )
{
case ImageReaderFactory.GIF:
return new GifReader( is );
case ImageReaderFactory.JPEG:
return new JpegReader( is );
// etc.
}
}
}
哪一个是事实上的“工厂方法”:getImageReader() 还是 GifReader 类的“<<”方法?