ASP.Net项目,一个大的dll和我糟糕的设计决策 [英] ASP.Net project, one big dll and my poor design decision

查看:64
本文介绍了ASP.Net项目,一个大的dll和我糟糕的设计决策的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从前,我有一个名为Intranet的.net小项目.它只是提供网页服务,并显示一些从数据库中检索到的数据.随着时间的流逝,一个怪物已经从这个小型的.net项目中成长出来.我添加了其他仪表板和报告功能,以及当时要求我执行的其他任何操作.现在,我有一个很大的.net项目,在一个dll中进行了太多操作,无法有效,快速地响应管理请求.

Once upon a time I had a little .net project called Intranet. It simply served up web pages, and displayed some data retrieved from a database. Over time a monster has grown out of this little .net project. I've added different dashboards and reporting functionality and whatever else was requested of me at the time. Now I have a big .net project with too much going on in the one dll to effectively and quickly respond to management requests.

例如,如果我需要对网站的一个逻辑区域中的某些功能进行快速更改,而我正在为网站的另一部分编写较大的功能,则我会陷入困境intranet.dll无法编译.我知道我可以分支我的源代码控制,但是我想做的是拥有多个dll.我希望每个逻辑功能区都有一个.

For example, If I need to make a quick change to some functionality in one logical area of the site and I'm in the middle of writing a larger piece of functionality for another part of the website I'm stuck with my intranet.dll not compiling. I know I could branch my source control but what I'd like to do is have multiple dlls. I'd like to have one per logical area of functionality.

我该怎么做?它是创建每个项目并复制代码的手动过程吗?我只想要一个用于整个过程的web.config.我还希望能够使用相同的成员资格提供程序来处理所有项目.我需要在Web服务器上进行哪些考虑?

How can I do this? Is it a manual process of creating each project and copying in the code? I'd like to have only one web.config for the whole thing. I would also like to be able to use the same membership provider handle all of the projects. What considerations do I need to make on the web server?

任何有关其他人如何处理此类问题的建议都将非常有帮助.

Any suggestions on how others deal with this sort of thing would be very helpful.

谢谢大家.

推荐答案

您可以开始重新设计,以使用更易于维护的体系结构升级项目.当然,这将需要时间和精力,但是最终您将获得出色的结果.

You can start re-designing to upscale your project with more maintainable architecture. And of course this will take time and effort but eventually you'll have great results.

这就是我的项目.

1.)应用程序基础设施

  • 所有业务对象的基类,业务对象集合,数据访问类以及作为扩展方法的我的自定义属性和实用程序,通用验证框架.这决定了我最终的.net应用程序的总体行为组织.

2.) Application.DataModel

  • 为数据库输入类型的数据集.
  • TableAdapters扩展为合并事务和我可能需要的其他功能.

3.) Application.DataAccess

  • 数据访问类.
  • 使用基础类型数据集查询数据库操作的实际位置.

4.) Application.DomainObjects

  • 业务对象和业务对象集合.
  • 枚举.

5.) Application.BusinessLayer

  • 提供可从表示"层访问的管理器类.
  • HttpHandlers.
  • 我自己的Page基类.
  • 这里还有更多东西.

6.) Application.WebClient Application.WindowsClient

  • 我的演示层
  • 从Application.BusinessLayer和Application.BusinessObjects中获取引用.

Application.BusinessObjects在整个应用程序中使用,并且需要时它们会遍历所有层[Application.DataModel和Application.Infrastructure除外]

Application.BusinessObjects are used across the application and they travel across all layers whenever neeeded [except Application.DataModel and Application.Infrastructure]

我所有的查询都仅定义为Application.DataModel.

All my queries are defined only Application.DataModel.

Application.DataAccess返回或将Business对象作为任何数据访问操作的一部分.业务对象是在反射属性的帮助下创建的.在数据库中,每个业务对象都具有映射到目标表的属性映射,在业务对象中的属性都具有映射到相应数据库表中的目标列的属性映射.

Application.DataAccess returns or takes Business objects as part of any data-access operation. Business objects are created with the help of reflection attributes. Each business object is marked with an attribute mapping to target table in database and properties within the business object are marked with attributes mapping to target coloumn in respective data-base table.

我的验证框架使我可以在指定的ValidationAttribute的帮助下验证每个字段.

My validation framework lets me validate each field with the help of designated ValidationAttribute.

我的框架大量使用属性来自动执行大多数繁琐的任务,例如映射和验证.我还可以将新功能作为框架中的新方面.

My framrwork heavily uses Attributes to automate most of the tedious tasks like mapping and validation. I can also new feature as new aspect in the framework.

示例业务对象在我的应用程序中将如下所示.

A sample business object would look like this in my application.

User.cs

[TableMapping("Users")]
public class User : EntityBase
{
    #region Constructor(s)
    public AppUser()
    {
        BookCollection = new BookCollection();
    }
    #endregion

    #region Properties

    #region Default Properties - Direct Field Mapping using DataFieldMappingAttribute

    private System.Int32 _UserId;

    private System.String _FirstName;
    private System.String _LastName;
    private System.String _UserName;
    private System.Boolean _IsActive;

    [DataFieldMapping("UserID")]
    [DataObjectFieldAttribute(true, true, false)]
    [NotNullOrEmpty(Message = "UserID From Users Table Is Required.")]
    public override int Id
    {
        get
        {
            return _UserId;
        }
        set
        {
            _UserId = value;
        }
    }

    [DataFieldMapping("UserName")]
    [Searchable]
    [NotNullOrEmpty(Message = "Username Is Required.")]
    public string UserName
    {
        get
        {
            return _UserName;
        }
        set
        {
            _UserName = value;
        }
    }

    [DataFieldMapping("FirstName")]
    [Searchable]
    public string FirstName
    {
        get
        {
            return _FirstName;
        }
        set
        {
            _FirstName = value;
        }
    }

    [DataFieldMapping("LastName")]
    [Searchable]
    public string LastName
    {
        get
        {
            return _LastName;
        }
        set
        {
            _LastName = value;
        }
    }

    [DataFieldMapping("IsActive")]
    public bool IsActive
    {
        get
        {
            return _IsActive;
        }
        set
        {
            _IsActive = value;
        }
    }

    #region One-To-Many Mappings
    public BookCollection Books { get; set; }

    #endregion

    #region Derived Properties
    public string FullName { get { return this.FirstName + " " + this.LastName; } }

    #endregion

    #endregion

    public override bool Validate()
    {
        bool baseValid = base.Validate();
        bool localValid = Books.Validate();
        return baseValid && localValid;
    }
}

BookCollection.cs

/// <summary>
/// The BookCollection class is designed to work with lists of instances of Book.
/// </summary>
public class BookCollection : EntityCollectionBase<Book>
{
    /// <summary>
    /// Initializes a new instance of the BookCollection class.
    /// </summary>
    public BookCollection()
    {
    }

    /// <summary>
    /// Initializes a new instance of the BookCollection class.
    /// </summary>
    public BookCollection (IList<Book> initialList)
        : base(initialList)
    {
    }
}

这篇关于ASP.Net项目,一个大的dll和我糟糕的设计决策的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆