Aspect-Oriented Programming : Aspect-Oriented Programming wi
Aspect-Oriented Programming : Aspect-Oriented Programming with the RealProxy ClassA well-architected application has separate layers so different concerns don’t interact more than needed. Imagine you’re designing a loosely coupled and maintainable application,but in the middle of the development,you see some requirements that might not fit well in the architecture,such as:
Any of these requirements need a lot of work and,more than that,code duplication. You have to add the same code in many parts of the system,which goes against the “don’t repeat yourself” (DRY) principle and makes maintenance more difficult. Any requirement change causes a massive change in the program. When I have to add something like that in my applications,I think,“Why can’t the compiler add this repeated code in multiple places for me?” or,“I wish I had some option to ‘Add logging to this method.’” ? The good news is that something like that does exist:?aspect-oriented programming (AOP). It separates general code from aspects that cross the boundaries of an object or a layer. For example,the application log isn’t tied to any application layer. It applies to the whole program and should be present everywhere. That’s called a crosscutting concern. AOP is,according to Wikipedia,“a programming paradigm that aims to increase modularity by allowing the separation of crosscutting concerns.” It deals with functionality that occurs in multiple parts of the system and separates it from the core of the application,thus improving separation of concerns while avoiding duplication of code and coupling. In this article,I’ll explain the basics of AOP and then detail how to make it easier by using a dynamic proxy via the Microsoft .NET Framework class RealProxy. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 管理页面来管理asp.net会员提供商和角色管理
- asp.net – 用于asp超链接的CSS
- asp.net-mvc – 为一个MVC视图使用两个强类型模型
- 优化ASP.Net / C中的循环#
- asp.net – web.config urlmapping
- 我可以通过编程方式从我的ASP.NET应用程序向IIS7
- asp.net-mvc-3 – 使用FluentValidation / MVC 3
- asp.net-core-mvc – ASP.NET Core MVC控制器在单
- asp.net-mvc – 在ASP.NET Core 1.1中配置基本身
- asp.net-core – 如何在VS2017 final中定位多个框