使用ABP框架踩過的坑系列1


    企業級(例如ERP)應用, 一遍一遍的在重復:認證、驗證、異常處理、日志、國際化和本地化、數據庫連接管理、配置管理、 審計記錄等,同時.NET有很多最佳實踐:分層、模塊化、DDD領域驅動、DI依賴倒置等,采用ABP就是基於這些慣例,來避免重復勞動,並且提供高質量、高效率的.NET開發。對於沒有專職架構師的小型公司來說,選擇ABP,可能是比較好的方案。萬事都有利有弊,使用框架帶來好處的同時,也有諸如學習曲線、踩坑等問題,本人使用ABP有3年多時間,實踐了幾個項目,踩過的坑有很多;想通過這個系列,把這些經歷分享給大家,希望給同志們帶來一些幫助。 
  誠如ABP的作者所說:We are creating different applications based on different needs. But implementing common and similar structures over and over again, at least in some level. Authorization, Validation, Exception Handling, Logging, Localization, Database Connection Management, Setting Management, Audit Logging are some of these common structures. Also, we are building architectural structures and best practices likeLayered and Modular Architecture, Domain Driven Design, Dependency Injection and so on. And trying to develop applications based on some conventions.    
 
   這張AbpLayers圖,實際上就是一個分層的最佳實踐,其實和通常的三層:UI界面層、BusinessLayer業務邏輯層、DAL數據訪問層,是相通的,只是把UI界面層分為PresentationLayer(Client)客戶展示層、WebLayer(server)服務器端的Web層,有些人把這分別叫前台、中台,DAL數據訪問層的抽象叫Infrastructure Layer基礎架構層,DAL數據訪問層的實現可以有多種實現,例如:EntityFramework、NHibernate、Dapper; BusinessLayer業務邏輯層,在DDD(領域驅動開發)中是核心,要用好ABP框架,了解DDD的一些核心概念是必須的,否則沒法得心應手的來使用,Enity、Repository是最起碼要了解的,如果還停留在Table和crud的舒適區層次,那建議您不要使用ABP。
public virtual void Initialize()
        {
            ResolveLogger();

            try
            {
                RegisterBootstrapper();
                IocManager.IocContainer.Install(new AbpCoreInstaller());

                IocManager.Resolve<AbpPlugInManager>().PlugInSources.AddRange(PlugInSources);
                IocManager.Resolve<AbpStartupConfiguration>().Initialize();

                _moduleManager = IocManager.Resolve<AbpModuleManager>();
                _moduleManager.Initialize(StartupModule);
                _moduleManager.StartModules();
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex.ToString(), ex);
                throw;
            }
        }

以上就是ABP的初始化,如果你認可DDD, 如果你認可SOLID, 如果你認可DRY, 如果你使用.NET或.NetCore, 如果你使用ASP.NET或ASP.NETCORE,  那說明你選到了最好的框架,沒有之一。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM