ASP.NET类库的最佳实践 [英] ASP.NET Class Library best practice
问题描述
我有一个包含很多类ASP.NET项目。
I have an ASP.NET project that contains many classes.
我想为类文件创建一个类库,从而使code可以在其他应用程序中重用。有两个选项:
I am thinking about creating a class library for the class files so that the code can be reused in other applications. There are two options:
1)创建一个包含所有类类库
2)只包含code将被共享,那么也许使用接口的类创建一个类库
1) Create a class library containing all the classes 2) Create a class library for only the classes that contain code that will be shared and then perhaps use interfaces
有选项2的任何真正的好处?选项1将是有益的,因为所有的code将在一个地方。
Is there any true benefits of option 2? Option 1 would be beneficial because all the code would be in one place.
推荐答案
我建议选择2#。
如果在code会被其他应用程序重用,我也不会增加额外的类在那里,因为这会扰乱库。我会把剩下的类在ASP.NET应用程序的特定于该应用程序的APP_ code文件夹中。
If the code will be reused by other applications, I wouldn't add the additional classes in there, as it would clutter up the library. I would put the remaining classes in the App_Code folder of your ASP.NET application that are specific to that application.
这篇关于ASP.NET类库的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!