Abstract Factory mode abstract factory provides a unified creation interface for a product family.
Abstract Factory Model
From: http://zh.wikipedia.org/wiki/%E6%8A%BD%E8%B1%A1%E5%B7%A5%E5%8E%82
Abstract Factory ModelAbstract Factory is a common design pattern.
This mode provides a unified creation interface for a product family.
When you need a series of productsAbstract FactorySelect the relative series to create a specific factory category.
Abstract Factory mode in FLC
In FLC, the typical method is dbconnection. createdbcommand.
The abstract class dbconnection indicates the connection to the database.
In the derived class, "odbcconnection" indicates an ODBC connection, "oracleconnection" indicates an Oracle database connection, and "sqlconnection" indicates an SQL Server database connection.
The abstract method createdbcommand is used to create the dbcommand of the respective database type in the derived class odbccommand,
Oraclecommand and sqlcommand return their parent class dbcommand.
When using the createdbcommand of the dbconnection object, you do not need to care about the database connection.
The class diagram is roughly as follows:
Because dbconnection itself acts as an abstract factory class, dbcommand is a product produced by a factory.