petshop4 架构说明(转)

日前微软推出了基于.NET Fram work 2.0开发的Petshop 4.新的Petshop4实现了与Petshop 3相同甚至更多的特性,由于采用了Master Pages,Membership,以及Profile,SqlCacheDependency,但是代码量却减少了四分之一.同时,在事务,数据缓存,安全方面使用了.NET 2.0附带的特性,构建了一个灵活的最佳实践的应用程序.

他们利用了Project Conversion Wizard把项目从ASP.NET 1.1移植到了ASP.NET 2.0,然后做了以下改动:
1.用System.Transactions代替了原来的Serviced Components提供的事务功能
代码实现:PetShop.BLL.OrderSynchronous 的 public void Insert(PetShop.Model.OrderInfo order).
2.用强类型的范型集合代替了原来的弱类型集合
public IList GetProductsByCategory(string category)
{
// Return new if the string is empty
if (string.IsNullOrEmpty(category))
return new List();
// Run a search against the data store
return dal.GetProductsByCategory(category);
}
3.采用ASP.NET 2.0 Membership来做认证和授权
4.创建了针对Oracle 10g的Custom ASP.NET 2.0 Membership Provider
5.利用ASP.NET 2.0的Custom Oracle 和 SQL Server Profile Providers 做用户状态管理,包括购物车等
6.采用了Master Pages,取代了原来的用户控件,来实现统一的界面效果
7.使用了ASP.NET 2.0 Wizard控件实现check-out
8.使用了SqlCacheDependency来实现数据库层次的缓存更新(cache invalidation)功能
9.使用了消息队列来实现异时订单处理.

1.整体架构:


数据库:(暂略)

项目列表:从整体可以看出,Pet Shop 4的项目体系已经很庞大,考虑的方面也较3.0更全面复杂。

 

2.petShop 4.0 的命名空间 以及各个项目模块的说明  

序号

项目名称

程序集名称Assembly Name 默认命名空间Default Namespace

描述

1

WEB

   

表示层

2

Model

PetShop.Model PetShop.Model

业务实体

3

BLL

PetShop.BLL PetShop.BLL

业务逻辑层

4

DALFactory

PetShop.DAL PetShop.DALFactory

数据层的抽象工厂

5

IDAL

PetShop.IDAL PetShop.IDAL

数据访问层接口定义

6

SQLServerDAL

PetShop.SQLServerDAL PetShop.SQLServerDAL

SQLServer数据访问层

7

OracleDAL

PetShop.OracleDAL PetShop.OracleDAL

Oracle数据访问层

8

DBUtility

PetShop.DBUtility PetShop.DBUtility

数据库访问组件基础类

9

CacheDependencyFactory

PetShop.CacheDependencyFactory PetShop.CacheDependencyFactory

缓存依赖类的工厂类

10

ICacheDependency

PetShop.ICacheDependency PetShop.ICacheDependency

缓存依赖类接口

11

TableCacheDependency

PetShop.TableCacheDependency PetShop.TableCacheDependency

缓存依赖实现类

12

IBLLStrategy

PetShop.IBLLStrategy PetShop.IBLLStrategy

同步/异步处理策略接口(实现在bll根据配置反射选择)

13

MessagingFactory

PetShop.MessagingFactory PetShop.MessagingFactory

异时处理消息队列的抽象工厂

14

IMessaging

PetShop.IMessaging PetShop.IMessaging

异时处理消息队列接口定义

15

MSMQMessaging

PetShop.MsmqMessaging PetShop.MsmqMessaging

异时处理消息队列的实现

16

Profile

PetShop.Profile PetShop.Profile

Profile的数据访问层

17

ProfileDALFactory

PetShop.ProfileDALFactory PetShop.ProfileDALFactory

ProfileDAL的工厂类(反射创建ProfileDAL)

18

IProfileDAL

PetShop.IProfileDAL PetShop.IProfileDAL

Profile的数据访问层接口定义

19

OracleProfileDAL

PetShop.OracleProfileDAL PetShop.OracleProfileDAL

Oracle的Profile Providers

做用户状态管理

20

SQLProfileDAL

PetShop.SQLProfileDAL PetShop.SQLProfileDAL

SQL Server 的Profile Providers

做用户状态管理

21

Membership

PetShop.Membership PetShop.Membership

Membership认证和授权管理

22

OrderProcessor

PetShop.OrderProcessor PetShop.OrderProcessor

后台处理进程,处理订单队列


  CSDN Blog推出文章指数概念,文章指数是对Blog文章综合评分后推算出的,综合评分项分别是该文章的点击量,回复次数,被网摘收录数量,文章长度和文章类型;满分100,每月更新一次。拨丝抽茧的来看,先不去管 Profile 和 Membership 和消息队列以及缓存。
3层结构主要的结构如下,最值得注意的地方当然是类工厂的使用了,在我看来,类工厂是最有用的模式之一,因为只有它能让我们摆脱对具体类的依赖而转而依赖抽象,依赖我们只需要的逻辑,而不去管实现的逻辑。



3.Petshop 4中的设计模式:

工厂模式:

首当其冲的就是工厂模式,很容易就可以看出来,也是应用最多的。

DALFactory:数据访问层的抽象工厂(决定创建哪种数据库类型的数据访问层。可以选择:SQLServer,Oracle)

CacheDependencyFactory缓存依赖类的工厂类。(创建具体表的缓存依赖)

MessagingFactory 异时处理消息队列的抽象工厂(反射创建具体的异时处理类

ProfileDALFactoryProfileDAL的工厂类(反射选择创建Oracle 和SQL Server的 ProfileDAL)

策略模式: IorderStrategy

 

中介模式

CategoryDataProxy ItemDataProxy  ProductDataProxy

 

原文地址:https://www.cnblogs.com/cuihongyu3503319/p/1003257.html