目前我正在使用 Autofac
进行 IoC。在两个组合根 (一个用于前端,一个用于后端) 中,我注册并解析跨越 Service
、 Business
和 Data
层的组件。
到目前为止,我的单一模块名称为“AccountingModule”。现在我要向应用程序中添加几个新模块,名称类似于 InventoryModule
,...
我的问题是,我应该将每个模块的类分别分布在各层中(方案1),还是每个模块都有独立的所有层(方案2)?
方案1:
Service Layer
(AccountingMoudle, InventoryModule, ...)
Business Layer
(AccountingMoudle, InventoryModule, ...)
Data Layer
(AccountingModule, InventoryModule, ...)
或者
解决方案2:
AccountingModule
(
Service Layer,
Business Layer,
Data Layer
)
InventoryModule
(
Service Layer,
Business Layer,
Data Layer
)
Edit 1
+-----------------------------+ +----------------------------+
+--+AccountingServiceComponent +-+InventoryServiceComponent
| Weak Dependency |
+--+AccountingBusinessComponent <------------------+ +-+InventoryBusinessComponent
| |
+--+AccountingDataComponent +-+InventoryDataComponent
+ +
+-+ GetDocumentByID(int id) +--+GetProductByID(int id)
| |
+-+ SaveDocument(Document d) +--+SaveProduct(Product p)
Edit 2 Architecture: