Content deleted Content added
No edit summary |
No edit summary |
||
Line 45:
1 - A bad way to design the ImageReader
This [[method]] has the [[advantage]] of abstracting the [[file type]] from the
Another [[solution]] that seems possible is to have a separate [[object]] for each of these file types:
Line 96:
Again, there are [[advantage]]s to this [[method]] (clean [[organisation]] of the ImageReader classes, split up in several classes), but this is at the [[cost]] of the [[abstraction]] of the image type. Again, when you get to have dozens of file types, this will be unsatisfactory and produce code that is hard to maintain.
So what's the [[solution]]? Simply to take the best of both worlds, by using the Factory pattern (which you should already have an idea of by now). The [[Factory]] is a
public class ImageReaderFactory
|