Factory method pattern: Difference between revisions

Content deleted Content added
FlaBot (talk | contribs)
m warnfile Adding:de
A better, but not perfect, solution: code cleanup, got rid of the casts
Line 42:
Another solution that seems possible is to have a separate object for each of these file types:
 
public Interfaceinterface ImageReader {
public DecodedImage getDecodedImage();
}
Line 70:
if( endsInDotGif( filename )) {
out = (ImageReader)new GifReader( fileInputStream );
}
if( endsInDotJpeg( filename )) {
out = (ImageReader)new JpegReader( fileInputStream );
}