Design Pattern series learned from FLC-creation pattern (2)-Abstract Factory

Source: Internet
Author: User
Tags odbc connection

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.