Content deleted Content added
m changed 'bung' to 'bundle' and removed a space before a question mark |
|||
Line 3:
=== Factory design pattern in Java ===
The Factory pattern is useful to solve a common problem: Very often you'll have to construct an [[Object (computer science)|object]], based on some [[input]], and the [[function (programming)|function]]s inside the object will depend upon the input. A good example would be a [[class (computer science)|class]] to read [[image file]]s and make [[thumbnail]]s out of them. You could, of course,
Line 84:
Again, there are advantages 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
public class ImageReaderFactory {
|