DotNetNuke (DNN) 2.x Module Architecture, Part II
| In this second part of a three part series we will cover the Business Logic Layer, and the Data Abstraction Layer of module Architecture of DotNetNuke. | |||
|
If you're not familiar with DotNetNuke, be sure you visit http://www.dotnetnuke.com to learn more about this fast growing open source portal that you can use and develop against absolutely free. In the previous article we discussed how to get your module project set up, we also began development on the user interface pieces of our module. In this article we're going into what makes the DNN architecture stand out from most .NET applications available, specifically the data provider model. The provider model is a dominant theme in the upcoming Visual Studio 2005 release, and is what makes DNN flexible enough to have any database as the backend. Here we will cover the Business Logic Layer, and Data Abstraction Layer of the DNN architecture, in part III of this series we will finish it up with an overview of the Database Provider class. BLL, and DAL I'm sure the previous acronyms are ones you've seen tossed around if you're an avid user of the ASP.NET forums. What do these stand for?
The custom business object helper class is basically a class that populates a collection of objects or objects that you created within your module. Usually these objects are directly related to stored procedures or queries from your database. Reflection versus Abstraction There are definitely plenty of changes here in DNN 2.x, in DNN 1.x we obtained data from our database using reflection. The major problem with the previous architecture of DNN was the lack of a clear definition between our different layers, i.e. data tier, business logic, and user tiers. Now with the provider model we have a clear separation of these tiers. Another big improvement in DNN 2.x architecture is performance. Thanks to abstraction and caching techniques there has been a huge performance increase as exhibited in the following metrics:
As you can see response time has been improved phenomenally! Business Logic Layer Now let's get into the different classes you will need to create for interacting with a database. In part I of this series we examined the user interface pieces of the survey module that comes bundled with the DNN distribution, now lets look at the BLL piece. In the survey example the BLL class is the SurveyDB.vb, in your modules you would follow the same naming convention, i.e.: ModuleNameDB. Within this file is at least two classes for your module, a ModuleInfo class and a ModuleController, for this example SurveyInfo, and SurveyController. Here's a description of these two classes:
Let's look at the SurveyInfo class and see what's going on in there:
Basically a simple class that is exposing prosperities for our controller class. Now let's look at the controller class:
.So what's going on the controller class? If you look at the code above you will see several methods, GetSurveys, GetSurvey, DeleteSurvey, AddSurvey, and UpdateSurvey. In most cases these routines directly correspond to a stored procedure contained within your database. For example, there is a GetSurveys stored procedure in our database that accepts ModuleID as a parameter, and returns a record. Now in the controller class you are doing something similar here, in the GetSurveys method you accept the ModuleID as input (which will be passed to the provider class for database execution). Then the return will be of type SurveyInfo. Remember in SurveyInfo we defined properties for our class, these properties normally correspond to fields contained within our database. We now create an collection object for our module to work with instead of a record set or data reader. This combined with the data provider classes is what provides abstraction from our vendor's database. Looking more into this class you see that the GetSurveys method first calls a CBO method, which is passed an instance of our data abstraction class. The CBO or custom business object class is what takes the data from our database via the data abstraction class, and then populates a collection of objects as the return to our BLL. So the main concept here is we don't directly work with data from database calls, our module deals with a collection of objects that contain properties that we defined in our SurveyInfo class. Another thing to note is when you are doing update, add, and delete operations there is no need to wrap your call within the CBO method, because in most cases there is no return coming from the database. |
浙公网安备 33010602011771号