Asp.net Design Pattern study notes -- PART 2

本文探讨了现有代码的弱点,如过重的存储过程、各层间职责不明导致的维护困难以及难以测试的问题。提出了一种新的架构解决方案,通过引入不同的层次来合理分配职责,使 UI 更轻便、每层易于测试,并利用 Entity Framework 优化存储过程。最终实现了一个更易于维护、扩展且具有良好测试性的系统。

Smart UI Architecture


Example:


What’s problem ?

1.store procedure is too heavy

2.Data access ,Business layer , service seems didnothing

3.UI is too heavy !

4.Hard to test !

As these weaknesses , these codes are very hard to maintain andextension .

Any solution ? maybe we can consider to refactor the architecture ! we need to make different layer do proper things !

Let’s see new architecture!




Now Let’s Apply this Architecture into the sample!

Let’s go through a Very sample feature , there is 2 drop down list control in aspx page, then I need to display the products by customer type :

1. Member (can have discountprice)

2. Non member (originalprice)

To implement this feature ,let’s see the new architecture :




Nowwhat’s changed ?

1. With presenter , UI not “fat” any more

2. Each layercan be tested

3. With EntityFramework , store procedure cannot be too “fat”

4. Service layer,Business layer, Data Access layer all have been assigned proper responsibilities,which makes maintainable and easy to be extended.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值