Recently in a set of CMS, found that there are members of the abstract factory This development model concept is not clear, should they ask, here I will briefly explain the relationship between the layers, the abstract factory model has not understood the friend can see, said the wrong place also please point out:
The so-called three-storey development, no outside:
Data access layer, business logic layer and display layer;
As forModel layer (interspersed with 3 layers, not in which, if really to calculate, can be considered as a data access layer, but essentially located between the database and the data Access layer);
The abstract factory model is based on the three-tier development to add a factory layer and interface layer, like my current project is such a few class Library: Entity class Library, interface class library, data Access Layer class library, factory class library, business logic Layer class library and display layer, as for the database class, can be considered as LINQ or in a tool class library.
One of the biggest functions of an abstract factory is the ability to switch databases easily (through the factory)
Well, tidy up (Take my recent CMS project as an example):
1. Entity Class Library Cmsmodels
2. Interface Class Library Icmsdal
3. Data access Layer Class library Cmsdal (Cmsdal refers to different database access layers, such as accessdal,mssqldal,oracledal)
4. Factory Class Library Cmsfactory
5. Business Logic Layer Class library CMSBLL
6. Display Layer website
7. Tool libraries or LINQ, etc.
Their relationships are:
Cmsdal inherit Icmsdal, implement the method inside, wherein the object of Icmsdal in the factory to be sent in handy;
Cmsfactory Select the database to use according to the parameters in the configuration file, and generate the corresponding instance;
CMSBLL, the corresponding "class" in Cmsdal is called through the data Access Layer object generated in cmsfactory;
WebSite, the method in the data access layer is called through the method in CMSBLL (the query database is the only way to get the result set).
PS: To cite an example
If there are 8 entity classes in the entity class, then there will be a corresponding 8 interface classes, corresponding 8 data access layer classes, corresponding 8 factory classes, corresponding to the classes in the 8 business logic layer, and their relationship is roughly as follows:
Suppose there is a article entity class--and then there is a Iarticledal interface--and there is a corresponding articledal--> corresponding to the Articlefactory--with the corresponding ARTICLEBLL, the resource manager is as follows:
Here the Accessdal and Mssqldal is what I said above the Cmsdal;
The function of the factory is to generate an example, as follows:
Factory layer to introduce system.web in advance, because here I am using the configuration file to get the database selection (whether SQL Server or access)
In the business logic layer:
The display layer does not have to tube the factory the thing, as long as calls the BLL layer method, in the above code calls the GetString () method, in the Accessdal and Mssqldal in the Articledal class has this method, as follows:
The Web. config code in the display layer:
Test code:
When value is set to 1 o'clock in the configuration file, the page will display "Here is SQL SERVER" and set to 2 o'clock, which will show "This is ACCESS"
Above
Attach this note with the solution: (Compiled in VS2010)
Http://www.kuaipan.cn/file/id_17032848158498515.htm
asp: Some descriptions of the abstract factory model (illustrated, illustrative)