Asp.net Design Pattern study notes -- PART 2

来源:互联网 发布:c语言函数库 chm 编辑:程序博客网 时间:2024/06/07 05:59

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 makedifferent 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.     Withpresenter , 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 makesmaintainable and easy to be extended.

 

原创粉丝点击