The Abstract factory pattern goes one level above in abstraction than Factory pattern. Here a concrete factory is provided for each concrete class and these concrete factories implement an abstract factory class. The advantage is that a single reference to abstract factory can be used to reference the concrete factories. This way all concrete classes have their own factories (they were not segregated in factory pattern).
e.g.
e.g.
abstract class AbstractFactory{
static AbstractFactory getFactory();
}
class Factory1 extends AbstractFactory{
getInstance(return (new Instance1));
}
class Factory2 extends AbstractFactory{
getInstance(return (new Instance2));
}
interface SomeInterface{
}
class Instance1 implements SomeInterface{
}
class Instance2 implements SomeInterface{
}
class Requester{
AbstractFactory abstfact = new Factory1();
abstfact.getInstance();
abstfact = new Factory2();
}
0 Comments On This Entry
← January 2022 →
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
My Blog Links
Recent Entries
-
-
-
SCJP Notes - Part 6on Mar 27 2008 08:19 AM
-
SCJP Notes - Part 5on Mar 27 2008 08:05 AM
-
Recent Comments
Search My Blog
11 user(s) viewing
11 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)



Leave Comment









|