Borrow And Spleb I also want to share with you the three-tier structure of my frequently-used systems. I also hope you will criticize and advise me.
System StructureWebFor example ):
1,Data Layer: There is nothing to say. database selection should be unrelated to the business logic. In general, the database is used as a container. No need to use the features of the database (maybe the performance is poor, but it is much lower than the cost of migration, let alone you do not wantM $OrIBMHold your root ?).
2,DLLMiddle Layer: This is the focus.
) Data Access ( dataaccess ): Provides the database access function. I usually use the ready-made database. I previously wrote a ydclasslibrary , SPL is used. As for what to use, it depends on the project scale. It also depends on the project size, small things like spleb access library, no 5 tables, no concurrency ......) Is it necessary to use Nhibernate ?
B) data definition ( datadefine ): data definition can also be a data entity ( dataentity ), this section provides the dataaccess layer ORM oo class. However, when you change the dataaccess , you need to change the datadefine . Generally, this layer is generated using the Code generator, which is not closely related to the specific business logic. The code generation tool depends on your dataaccess . ydclasslibrary ydcodemaker , use SPL to write spleb . Alternatively, use codesmith . Haha.
C)System Support (Systemframework): Provides system framework support, such as exceptions and logs. There are also ready-made, suchLog4net.
D)Business Logic (Businessrule): The logic abstraction in the requirement provides some functions. For example, a user's information is converted and encrypted.
E)Business appearance (Businessfacade): Encapsulates the business layer and provides business entities (BusinessEntity), And related businessFa C AdeClass. The interface provided on the previous layer. You can also setBusindessentityExtracted separately as a part. This depends on the specific situation. If it is largeBusinessFull EncapsulationDatadefinePart, that is, you only need to knowBusinessfacadeYou can.
3,Presentation layer (Webform or winform) There's nothing to say. Let's see how you write it,WebOrWinform, Random, what?AjaxAh,WebServicesYes.
Note:
1,My three-tier structure is similar to the example given by Microsoft. It is mainly focused on practical and rapid development. Stability and performance are both considered. To maximize the use of existing resources, especially free and open-source resources, reuse reduces costs!
2,For the presentation layer, you need to understandBusinessfacadeClass. For small systems, sometimesDataentityAndBusinessEntitySo the presentation layer can also be used directly.Dataentity. I think encapsulation is a relative problem. It doesn't make any sense to encapsulate just for encapsulation. To implement the function first, we haveTDDTherefore, we can constantly refactor. Of course, the design model is also very important, but our goal is to achieve the final system, always remember that we are making products, not works of art.
3,Development mode. First, of course, it is the design, business object, business logic, and so on. Then, when designing a certain stage, I recommend that you first make a prototype orUI(WebIs the page design,WinformIs a form), and communicates with the customer, so that you can grasp the needs, design is more accurate, and can greatly avoid rework. Then I almost started database design. For more information, see my other article.ArticleHttp://yuandong.cnblogs.com/archive/2006/02/04/325303.html ). As long as the database design is complete,DataaccessAndDatadefineAll of them are automated.
4,Business logic, which is the most difficult to write.OOA/dAndTDDThe combined mode is implemented cyclically. Database changes are indispensable in this process. Fortunately, our data access is all automatic and it is easy to adapt to changes in requirements.
5,When we enter the presentation layer, all the business logic should have passed the unit test. We have enough classes to build our appearance. If you have already designed the interface, it would be too easy, equipment, debugging, and everything.OK.
For specific implementation, I will useSplebFor example, please follow my next article
SplebDevelopment log-three-tier structure (2) Implementation