什么是AOP?
:) = Aspect Oriented Programming
Business Rule | (AOP)
Security Permission |
Logging | --------------> Business Logic
Database Operations |
Web Service |
为什么AOP?
为了独立业务
怎样AOP?
举个例子
按照传统的写法写登陆业务
1
/**/
/* Traditional Way */
2
bool
isAdministrator
=
false
;
3
if
(Users.ValidateUser(Context.User.UserName)
==
UserRole.Admministrator)
4
{
5
isAdministrator = true;
6
}
7
if
(
!
isAdministrator)
throw
new
NoPermissionExpection();
8
//
Bussiness Code
9
/**/
/* -----------------------------------------------------------------
10
* Aspect Oriented Programming
11
* AOP指的是用面向方面的编程来解决面向方面的问题
12
* 一般包含: 1.切入点 2.方面问题的解决
13
* 在实现中一般加入了动态代理的成分反倒复杂了许多,包含了五个方面
14
* 1. 连接点 2. 接入点 3. 通知 4.方面 5. 引入
15
------------------------------------------------------------------*/
16
if
(
!
Memebership.User.HasPermission)
throw
new
NoPermissionExpection();


2

3

4



5

6

7

8

9


10

11

12

13

14

15

16

关于动态代理的部分
例如:



















框架
Spring, Aspect# 等等
关于AOP更多描述:
http://www.jdon.com/AOPdesign/jdon-aop.htm
http://wayfarer.cnblogs.com/articles/241024.html