22/08/2006
從 Separation of Concerns 談 AOP 與 SOA
AOP (Aspect-oriented Programming) 強調的是面向分割 (separation of concern),並且試圖由程式語言 (compiler)、框架 (framework) 或執行期 (runtime) 層次對橫切物件功能的服務考量 (crosscutting concerns) 提供支援。
AOP 本身是開發應用程式框架的有力工具,透過 AOP 的手法,可以輕易解決傳統 OOP 窒礙難行的問題。例如充斥在整個系統中的橫切服務--包括日誌、交易、安全的議題,都可透過 AOP 的支援而輕易實作出來。
不過 AOP 也引入一些問題,例如透過 AOP 手法建築的系統,其元件間的互動關係較難以理解及追蹤,因此個人認為 AOP 適用於開發 application framework 的底層,但卻並不適合拿它直接來開發應用系統。
而個人對於 SOA 所謂的 Concerns 則有二種看法:
- Business Concerns: 如何達到 (business) services independency
- 如同 AOP 中之 crosscutting concern:這在 SOA 中給它負予了一個可怖的稱謂,叫 Enterprise Concerns,其實也不過就是 log, monitor, access rights 這些非使用者功能導向的服務需求。不過 SOA 不在程式語言、編譯器或框架(framework)上解決此議題,而在架構層級解決
SOA 之所以也能達到 separation of concerns 的訴求,完全是因為它將服務的兩端抽象化,並將呼叫訊息化。在 client 與 service 之間,可以加入許多的 proxy, router, interceptor 這樣的東東,因此可以在兩造之間加入許多的 QoS(Quality of Services, 即上述的 Enterprise Concerns)。
這樣一來,這些 QoS 就可獨立出來個別設計,再於佈署時期或執行時期動態的設定,也就達到 separation of concerns 的訴求。從這個面向來說,SOA 達到了最為動態的 AOP。不過,相對的 SOA 之切點的設定便無法如傳統 AOP 的作法 (在程式語言上下功夫) 那樣的精密了。
13:35 發表於 Developing | 永久網址 | 留言 (0) | Email this | Tags: SOA, design, AOP, OOP, framework
08/02/2004
Java: AOP
To understand the spirit of AOP, you must understand the following issues:
- separation of concerns: referring the Law of Demeter, a project's efficiency increases if all the concerns are well modularized and if you only have to speak to your direct friends to make a modification of the program (this is a very old principle and the OOP gives some answers)
- crosscutting: in a complex system, there are always some concerns that are not easily modularized, especially common-interest concerns that, by essence, are used by several modules (i.e. several modules use/share a well-known service of a module --such as a logging or a persistence service)
- dependencies inversion: the best way to avoid crosscutting is to NOT use the well-known services that crosscut. This is possible by reversing the dependencies (i.e. the well-known service shall use the other modules instead of the contrary). This dependency inversion is implemented by aspects...
Projects:
- Aspectj
- JAC
- Nanning Aspects AOP framework
- AspectWerkz is a dynamic, lightweight and high-performant AOP/AOSD framework for Java. AspectWerkz utilizes runtime bytecode modification to weave your classes at runtime. It hooks in and weaves classes loaded by any class loader except the bootstrap class loader. It has a rich join point model. Aspects, advices and introductions are written in plain Java and your target classes can be regular POJOs. You have the possibility to add, remove and re-structure advices as well as swapping the implementation of your introductions at runtime. Your aspects can be defined using either an XML definition file or using Runtime Attributes
See also:
- ASOD - the home for the Aspect-Oriented Software Development.
- I want my AOP!
- Aspect Programming: Aspect Programming provides software development and training services. We are based in the Seattle area. The services we provide to our clients include:
- Analysis, design, and implementation services for software projects
- Project and Product management
- Expertise in Intenet, Wireless, and Enterprise Java technologies
- Design and code reviews
- Training and mentoring
- Improve modularity with aspect-oriented programming: Aspect-oriented programming (AOP) is a new programming technique that allows programmers to modularize crosscutting concerns (behavior that cuts across the typical divisions of responsibility, such as logging). AOP introduces aspects, which encapsulate behaviors that affect multiple classes into reusable modules. With the recent release of AspectJ by Xerox PARC, Java developers can now take advantage of the modularization AOP can provide. This article introduces AspectJ and illustrates the design benefits that result from its use.
- Aspect Mentor: AspectMentor is a consortium of experts in aspect-oriented software development.
We can help your organization adopt and work with aspect-oriented programming technologies. Our consultants provide services including:
- Training: tutorials and seminars of varying lengths on topics including AspectJ, AOP frameworks, and AOP for enterprise computing.
- Mentoring: design, pair programming, code reviews, proof of concepts and prototyping, and tool and platform integration.
- Project planning: choosing and designing pilot projects, planning adoption strategies, and integrating AOSD into existing systems.
- Proposal writing: creating effective proposals for new AOP projects.
05:00 發表於 Developing | 永久網址 | 留言 (0) | Email this | Tags: Programming, java, aop, resources


