Design Patterns: Abstract Factory Pattern
Design Patterns: Abstract Factory Pattern
Design Patterns: Abstract Factory Pattern
Option 1:
SingleConcreteFactory implemented using
a procedural approach.
Drawback: Not ideally object oriented
Option 2: database
TaxProcessor createTaxProcessor () {
String query = “SELECT CALC_TAX FROM mytable
WHERE ID = " + ID;
ResultSet myResults =getQueryResults(query);
String classToInstantiate;
classToInstantiate=
myResults.getString("CALC_TAX");
return Class.forName(classToInsantiate);
}
Consequent Forces
Testing
testcan use type-checking to determine that
the proper concrete types are created under
the right set of circumstances
Cost benefits
Flexible for adding a new family or changing
the implementation of present
But if an entirely new abstract concept
enters, eg trade restrictions to a new
country
References
http://www.apwebco.com/gofpatterns/creation
http://www.netobjectivesrepository.com/TheA
Questions????
Thank you!