1. 程式人生 > >使用ABP框架中踩過的坑系列1

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

誠如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.  企業級(例如ERP)應用, 一遍一遍的在重複:認證、驗證、異常處理、日誌、國際化和本地化、資料庫連線管理、配置管理、 審計記錄等,同時.NET有很多最佳實踐:分層、模組化、DDD領域驅動、DI依賴倒置等,採用ABP就是基於這些慣例,來避免重複勞動,並且提供高質量、高效率的.NET開發。對於沒有專職架構師的小型公司來說,選擇ABP,可能是比較好的方案。萬事都有利有弊,使用框架帶來好處的同時,也有諸如學習曲線、踩坑等問題,本人使用ABP有一年多時間,實踐了3個專案,踩過的坑有很多;想通過這個系列,把這些經歷分享給大家,希望給同志們帶來一些幫助。

這張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。