Asp.net Design Pattern study notes -- PART 2

Smart UI Architecture

Asp.net Design Pattern study notes -- PART 2_第1张图片

Example:

Asp.net Design Pattern study notes -- PART 2_第2张图片

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!

Asp.net Design Pattern study notes -- PART 2_第3张图片

Asp.net Design Pattern study notes -- PART 2_第4张图片

Asp.net Design Pattern study notes -- PART 2_第5张图片

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 :

Asp.net Design Pattern study notes -- PART 2_第6张图片

Asp.net Design Pattern study notes -- PART 2_第7张图片

Asp.net Design Pattern study notes -- PART 2_第8张图片


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.

你可能感兴趣的:(Pattern,design)