A four-layer application architecture [CBOFRAMEWORK C # Beta 1]

zhaozj2021-02-17  82

A four-layer application architecture [CBOFRAMEWORK C # Beta 1]

Mood

2002-5-12

Article Type: Overview

Difficult Level: 7/9

Version: 3.22

With regard to the topic of the application system architecture under the DOTNET, we can clearly start from a point, but may not end, never :) A large number of original COM programmers began to walk between COM and DOTNET, busy Transfer your focus and applications to the DOTNET architecture, on the one hand, take care of the original COM. Finally, these programmers will face both after a certain learning curve, master how to interact with both, and the tricks of both. But the problem may just start, because they will soon start asking such a question: What is the process of future procedures? What is the architecture of the program?

Too many program frameworks, let them start a lot of dazzling, new concepts and technologies seem too much, mastering these concepts will find a feeling of unlikely, you don't know that the way is relatively best. Paul D. Sheriff (PDSA, Inc.) published the article of Designing a .NET Application (Updrading to Microsoft.Net) on the MSDN at the end of April, which has summarized several program frames and their own characteristics. . In fact, when you use ADO.NET, ASP.NET, COM , Web Services, XML, Remoting, DCOM / SOAP / HTTP, you can combine 20 three or multi-layer architectures. Also add MSMQ and SQLXML.

Part of the programmer has begun some complaints, and the architecture under the DOTNET seems to be over-open relative to the strict specification of J2EE. I believe that this state will continue for a while, and Microsoft also needs to experience an optimized and integrated process to make effective and constructive guidance and recommendations. In the previous time, the choice of application architecture may fall to ISV and developers.

After a period of development, there are some principles that have been summed up and more and more applications, such as:

1. Use unified and robust DAL (Data Access Layout) and storage procedures, making the data service layer more interface and efficient.

2. Apply object-oriented analysis and design to smooth business layer components and objects to smoothly use design modes to improve reusability.

3. Designfully consider the interfaces and features facing Web Services.

4. Use DOTNET interfaces and properties to make three layers more detailed and hierarchical to provide higher levels of abstraction.

5. The interface between layers and layers is increasingly "loosely coupled", stability and flexibility.

6. Reduce the specific gravity of COM , COM is exactly distributed, multi-database and core middleware.

7. Commercial logic is more refined, and the realization of a specific gravity is moved from the commercial logic layer to the performance layer, and is completed by the multi-storey.

8. Web Server starts slowly become a controller that is closest to the client's recent business logic proxy and resource, permission.

9. WebForm and WinForm provide a rich UI, making the performance layer with more energy to handle user sessions, login, permissions, etc.

10. XML and Schema are more applications in the design, often become a "glue" and medium of contact between multiple layers in the system.

The four-layer application architecture you want to say is from 11 of 11 chapters in DESIGNING Solutions With COM Technologies. Wade Baron adjusts the original three-layer structure, one is to implement client objective access, and the other is to divide the business logic layer into transaction service layer and object service layer, the object service is located in the performance layer (client), transaction Serving the original business logic layer, located on the server side. Specifically, the CBOFramework framework reflects some of the features of the above 2, 4, 7, 10, especially the object-oriented design and analysis, ending the confusion of the business object returns an ADO record set, so that the performance layer There are more energy to handle your logic. On the other hand, due to abstraction and objectization, it is possible to apply a variety of design patterns currently known.

The CBOFramework also uses Collection's technology and concepts, but it is different from the ECC (Engine-Collection-Class) Framework described earlier (Microsoft) and LEO Romano (Sierra System Group INC). CBO can also apply Object Factory or other design patterns, but as the core design, CBO does not emphasize design mode, but reflects interface programming and object-oriented analysis technology. In the performance, CBO does not have ECC, I personally think that CBO is more powerful and advanced, and the load is much smaller than the Collection of the ECC, and because the interface design is easier to expand, such as the DOTNET new Remoting, As a distributed agreement, the SOAP protocol, of course, both do not conflict, understanding ECC is a great help to understand CBO, because both are somewhat identical.

Due to the limited space, I will not translate the design ideas and descriptions of the original text, and it is highly recommended to get more detailed design ideas and internal processes from the original and books. This article will provide the original class diagram representation (this is obtained from the reverse engineering of Visual Studio.net) I will be re-written in the way the entire frame is re-written in C #. (The author provides a Visual Basic version of Project) , The performance layer, I didn't use the author, but I rereaded a simple test, and I would like to use the author's example in the future because his client implements better and more complete). In addition, the Shippers object (three classes) I have not done because some objects of the framework are basically the process of Copy / Paste. The database used by the example is the sample database of the famous Northwind in the SQL Server and the MS Access database, and has not been deleted.

The environment you need: Visual Studio.NET EN RTM , SQL Server 2000 SP2.

Details and implementation:

The entire framework defines four interfaces, an implementation of a persistence of an object and an implementation of an Object Collection.

Interface: IPersistObjectStream and IObjectStream are client interfaces

Interface: IPersistTransStream and Itransstream are server-side interfaces.

CBocollection is an Object Collection implementation that is used to implement a collection of objects.

All gathers for each object such as: Customers, Orders, etc. must have a collection object, because the DOTNET does not provide Generic Porgramming feature (Templates), the collection object for each Type-Safe to each real object will be painful. Here I use the Collectiongen tool provided by Chris Sells, generating an Object type Universal CBO Object Collection. (The production speed is very fast, and it is very convenient but not type-safen, which means there will be a certain type of conversion performance, too many collection objects, one generation seems to be too ....) CSTREAM implements IObjectStream and Itranstream, this The class implements the object's object to be kept in the database (in persistence). This class is currently using XML so that the client will sequence the object to this XML stream by revealed interfaces; while the server-side transaction object can read data from the interface disclosed from this object.

Transaction Services (Transaction Services)

All transaction layer objects must implement iPersistTransStream, which is called to write data to the database. Below is an implementation of a Customers transaction object

Object Services (Object Services)

Objects of objects: objects and object collections must implement the IPersisObjectStream interface. This interface is mainly used by current objects to load objects from the XML stream and saving the object state to the XML data stream.

Client:

The benefits of using CBOFRAMEWORK can be optimized at the client, and now the performance layer users can completely put their own energy on the interface of the performance layer and the processing of the business logic process, without paying the sequence and type conversion of the set field. Users of the performance layer can make more easier to use these similar objects to program and operate, achieve corresponding to the business process.

Typical DNA Architecture CBOFramework Get Object DIM RETRST AS AS Object Set Customer = CreateObject ("Custom") Set RetrSt = Customer. GetByCustomerid (TXTSEARCH.TEXT)

CCUSTOMERS M_OCUSTOMERS = NULL;

CCUSTOMER M_OCUSTOMER = NULL

M_OCUSTOMERS = New CCUSTOMERS ();

M_OCUSTOMER =

m_ocustomers.getbycustomerid (TXTSearch.Text)

Binding txtcompany.text = retrST ("Company") txtContact.text = retrST ("Contact") txtttitle.text = retrST ("Title") txtaddress.text = retrST ("address") txtcity.text = RETRST ("city ") txtCompany.Text = m_oCustomer.Company; txtContact.Text = m_oCustomer.Contact; txtTitle.Text = m_oCustomer.Title; txtAddress.Text = m_oCustomer.Address; txtCity.Text = m_oCustomer.City; modified lret = Customer.UpdateAddress (Addre ) m_ocustom.address = addre; m_ocustom.save (); Delete Lret = Customer.deletecustomer (CUID) m_ocustomer.delete (); new LRET = Customer.AddNew (A1, A2, A3 ...) m_ocustom = new ccustomer (); m_ocustomer.campany = a1; m_ocustom.contact = a2; ......... m_ocustomer..save (); of course, it simplifies some, some records, calculations, calculations, etc. under typical DNA architecture, the facts These logic often chaos in the code of the performance layer. CBOFramework finally reaches our goal: improve reusability, code is more simple and easy to maintain.

future:

This is the first version of CBOFramework, and its goal is to understand its architecture and implement it on the DOTNET platform. It must be recognized that this version is very primitive and simple, there are still many unpleassed. It only clarifies the entire framework, showing an implementation and application of this framework, I want to make more supplements and adjustments to CBOFraMework in the future, such as the next version adds some of the features:

1. Currently, it is not a real distributed, all transaction service layer objects have not inherited from ServicedComponent (I note this may not be the final program), then the communication (non-this machine) of the object service layer and transaction service layer must Through DCOM, it is to package deployment in COM . The next version will implement Remoting protocol communication in the object service layer and transaction service layer, of course, it is best to compatible with DCOM.

2. Implement a universal DAL or DAO (Data Access Object), a unified transaction service layer for database access, making it compatible with MSSQL, XML, OLEDB, and SQLXML.

3. Improve the application's instance, and by using a design pattern created, the original author's VB instance (COM user) can be transparently using new components. Also add examples of ASP.NET.

4. Make the XML function used in the frame to unify an XMLHELP class for use.

5. Based on the above CBocolection description, the implementation of this class is shifted from the namespace of CBOFRAMEWORK, putting the namespace of the second level, which is convenient for users of the framework for use to implement their own Object Collection class.

to sum up:

We basically discuss a modified version of the architecture related to the original Windows DNA: a four-layer structure. This structure adjusts the classification of the three-layer structure and introduces object-oriented design and analysis. In addition, CBOFramework uses interface and flow concepts to implement an object persistence (object to the mapping of the relational database). The entire CBOFraMework fully uses interface definitions, so it is very beneficial to expand and improve. Personally think that this framework is more important than using this framework; although it is still very thin, I think this will start a good start. Source code: [CBOFrameworkLib 134K]

especially:

This article original 9CBS signature start, all text and image copyright. Do not spread, reprint or adapt unauthorized

If you have any questions or suggestions, please email new2001@msn.com

The source code in CBOFrameworkLib belongs to demo, without any terms and permit, anyone can use it.

The Source code and e-books of the original VB version of the "Designing Solutions With COM Technologies" book. The book Chinese version "COM Technology Solution Design" has been published by Machinery Industry Press, 2001.09

Finally, I would like to thank 9CBS to provide source code space.

转载请注明原文地址:https://www.9cbs.com/read-30993.html

New Post(0)