Lập trình hướng khía cạnh
Trong điện toán, lập trình hướng khía cạnh (tiếng Anh: aspect-oriented programming, viết tắt: AOP) là một mẫu hình lập trình nhằm tăng tính mô đun bằng cách cho phép phân tách những mối quan tâm xuyên suốt. Nó làm như vậy bằng cách thêm hành vi bổ sung vào mã đã tồn tại (một lời khuyên) mà không sửa đổi chính mã đó, thay vì xác định cụ thể mã nào được sửa đổi thông qua một đặc tả "điểm cắt" (pointcut), ví dụ như "lưu lại (log) tất cả lời gọi hàm khi tên hàm bắt đầu với từ 'set'". Điều này cho phép những hành vi không phải là trung tâm của logic nghiệp vụ (ví dụ như lưu lại) được thêm vào chương trình mà không làm rối lõi của mã đến các chức năng. AOP tạo cơ sở cho phát triển phần mềm hướng khía cạnh (aspect-oriented software development).
AOP bao gồm các phương thức và công cụ lập trình hỗ trợ cho mô đun hóa các mối quan tâm ở mức độ mã nguồn, trong khi "phát triển phần mềm hướng khía cạnh" dùng để chỉ đến toàn bộ một nguyên lý công nghệ.
AOP đòi hỏi chia nhỏ logic của chương trình thành các phần riêng biệt (gọi là mối quan tâm hay concern, là những khu vực liên kết các chức năng). Gần như các mẫu hình lập trình đều hỗ trợ các mức độ gom nhóm và đóng gói các mối quan tâm thành các thực thể riêng biệt và độc lập bằng cách cung cấp khả năng trừu tượng (ví dụ, các hàm, thủ tục, mô đun, lớp, phương thức) để có thể dùng cho hiện thực, trừu tượng và bố cục những mối quan tâm đó. Vài mối quan tâm "cắt xuyên qua" nhiều trừu tượng trong một chương trình, và gây khó khăn cho hiện thực - chúng được gọi là những mối quan tâm xuyên suốt (cross-cutting concern hay horizontal concern).
Hiện thực
Các ngôn ngữ lập trình sau có hiện thực AOP, trong ngôn ngữ đó, hay thông qua thư viện ngoài:
- .NET Framework (C# / VB.NET)[1]
- PostSharp
- Unity
- ActionScript[2]
- Ada[3]
- AutoHotkey[4]
- C / C++[5]
- COBOL[6]
- Cocoa Objective-C frameworks[7]
- ColdFusion[8]
- Common Lisp[9]
- Delphi[10][11][12]
- Delphi Prism[13]
- e (IEEE 1647)
- Emacs Lisp[14]
- Groovy
- Haskell[15]
- Java[16]
- AspectJ
- JavaScript[17]
- Logtalk[18]
- Lua[19]
- make[20]
- Matlab[21]
- ML[22]
- Perl[23]
- PHP[24]
- Prolog[25]
- Python[26]
- Racket[27]
- Ruby[28][29][30]
- Squeak Smalltalk[31][32]
- UML 2.0[33]
- XML[34]
Xem thêm
Ghi chú và tham khảo
Đọc thêm
- Kiczales, G.; Lamping, J.; Mendhekar, A.; Maeda, C.; Lopes, C.; Loingtier, J. M.; Irwin, J. (1997). Aspect-oriented programming (PDF). ECOOP'97. Proceedings of the 11th European Conference on Object-Oriented Programming. LNCS. 1241. tr. 220–242. CiteSeerX 10.1.1.115.8660. doi:10.1007/BFb0053381. ISBN 3-540-63089-9. The paper generally considered to be the authoritative reference for AOP.
- Andreas Holzinger; M. Brugger; W. Slany (2011). Applying Aspect Oriented Programming (AOP) in Usability Engineering processes: On the example of Tracking Usage Information for Remote Usability Testing. Proceedings of the 8th International Conference on electronic Business and Telecommunications. Sevilla. D. A. Marca, B. Shishkov and M. v. Sinderen (editors). tr. 53–56.
- Robert E. Filman; Tzilla Elrad; Siobhán Clarke; Mehmet Aksit (2004). Aspect-Oriented Software Development. ISBN 0-321-21976-7.
- Renaud Pawlak, Lionel Seinturier & Jean-Philippe Retaillé (2005). Foundations of AOP for J2EE Development. ISBN 1-59059-507-6.
- Laddad, Ramnivas (2003). AspectJ in Action: Practical Aspect-Oriented Programming. ISBN 1-930110-93-6.
- Jacobson, Ivar; Pan-Wei Ng (2005). Aspect-Oriented Software Development with Use Cases. ISBN 0-321-26888-1.
- Aspect-oriented Software Development and PHP, Dmitry Sheiko, 2006
- Siobhán Clarke & Elisa Baniassad (2005). Aspect-Oriented Analysis and Design: The Theme Approach. ISBN 0-321-24674-8.
- Raghu Yedduladoddi (2009). Aspect Oriented Software Development: An Approach to Composing UML Design Models. ISBN 3-639-12084-1.
- "Adaptive Object-Oriented Programming Using Graph-Based Customization" – Lieberherr, Silva-Lepe, et al. - 1994
- Zambrano Polo y La Borda, Arturo Federico (ngày 5 tháng 6 năm 2013). “Addressing aspect interactions in an industrial setting: experiences, problems and solutions”: 159. Truy cập ngày 30 tháng 5 năm 2014. Chú thích journal cần
|journal=
(trợ giúp) - Wijesuriya, Viraj Brian (2016-08-30) Aspect Oriented Development, Lecture Notes, University of Colombo School of Computing, Sri Lanka
Liên kết ngoài
- Eric Bodden's list of AOP tools in.net framework
- Programming Styles: Procedural, OOP, and AOP
- Programming Forum: Procedural, OOP, and AOP Lưu trữ 2011-10-24 tại Wayback Machine
- Aspect-Oriented Software Development, annual conference on AOP
- AOSD Wiki, Wiki on aspect-oriented software development
- AspectJ Programming Guide
- The AspectBench Compiler for AspectJ Lưu trữ 2014-12-16 tại Wayback Machine, another Java implementation
- Series of IBM developerWorks articles on AOP
- A detailed series of articles on basics of aspect-oriented programming and AspectJ Lưu trữ 2013-07-26 tại Wayback Machine
- What is Aspect-Oriented Programming? Lưu trữ 2009-08-21 tại Wayback Machine, introduction with RemObjects Taco
- Constraint-Specification Aspect Weaver
- Aspect- vs. Object-Oriented Programming: Which Technique, When? Lưu trữ 2021-04-15 tại Wayback Machine
- Gregor Kiczales, Professor of Computer Science, explaining AOP, video 57 min.
- Aspect Oriented Programming in COBOL Lưu trữ 2008-12-17 tại Wayback Machine
- Aspect-Oriented Programming in Java with Spring Framework
- Wiki dedicated to AOP methods on.NET
- Early Aspects for Business Process Modeling (An Aspect Oriented Language for BPMN)
- Spring AOP and AspectJ Introduction
- AOSD Graduate Course at Bilkent University
- Introduction to AOP - Software Engineering Radio Podcast Episode 106
- An Objective-C implementation of AOP by Szilveszter Molnar Lưu trữ 2012-08-01 tại Wayback Machine
- Aspect-Oriented programming for iOS and OS X by Manuel Gebele
- Java Method Logging with AOP and Annotations by Yegor Bugayenko
- DevExpress MVVM Framework. Introduction to POCO ViewModels