计算机专业时文选读(971)

软考 rubberface 浏览 1372 来源:希赛网

Aspect-OrientedProgrammingAspect-orientedprogramming(AOP)isanapproachtoprogrammingthatallowsglobalpropertiesofaprogramtodeterminehowitiscompiledintoanexecutableprogram.TheconceptualizersofAOPcompareaspectprogrammingtothemanufacturingofclothinwhichthreadsare

Aspect-Oriented Programming

Aspect-oriented programming (AOP) is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program. The conceptualizers of AOP compare aspect programming to the manufacturing of cloth in which threads are automatically interwoven. Without AOP, programmers must stitch the threads by hand.

AOP complements object-oriented programming by allowing the developer to dynamically modify the static object-oriented model to create a system that can grow to meet new requirements, allowing an application to adopt new characteristics as it develops.

AOP provides a solution for abstracting cross-cutting code that spans object hierarchies without functional relevance to the code it spans. Instead of embedding cross-cutting code in classes, AOP allows you to abstract the cross-cutting code into a separate module (known as an aspect) and then apply the code dynamically where it is needed. You achieve dynamic application of the cross-cutting code by defining specific places (known as pointcuts) in your object model where cross-cutting code should be applied. At runtime or compile time, depending on your AOP framework, cross-cutting code is injected at the specified pointcuts. Essentially, AOP allows you to introduce new functionality into objects without the objects’ needing to have any knowledge of that introduction.

Aspect-oriented software development (AOSD) is a new approach to software development that addresses limitations inherent in other approaches, including object-oriented programming. AOSD aims to address crosscutting concerns by providing means for systematic identification, separation, representation and composition. Crosscutting concerns are encapsulated in separate modules, known as aspects, so that localization can be promoted. This results in better support for modularization hence reducing development, maintenance and evolution costs.

The following terms are often used in AOP:

Aspect An aspect is a subprogram that is associated with a specific property of a program. As that property varies, the effect “ripples” through the entire program. The aspect subprogram is used as part of a new kind of compiler called an aspect weaver.

Aspect is a construct, resembling classes, for addressing concerns that cut across classes. An aspect can contain methods and fields, extend other classes or aspects, and implement interfaces.

Aspects in AOP package advice and pointcuts into functional units in much the same way that object-oriented programming uses classes to package fields and methods

AspectC++ An aspect-oriented extension to the C++ programming language.

AspectJ An aspect-oriented extension to the Java programming language.

Advice Code that runs after certain conditions are met. Advices allow you to transparently apply things like logging and metrics to an object model..

Concern Some functionality or requirement necessary in a system that may or may not have been implemented in a code structure. Concerns can range from high-level notions like security and quality of service to low-level notions such as caching and buffering. They can be functional, like features or business rules, or systemic, such as synchronization and transaction management.

Crosscutting Two concerns crosscut if the methods related to those concerns intersect. An aspect crosscuts the traditional class and method boundaries by applying the same code in each.

Interceptor Used to implement an advice in JBoss 4.0, a popular Java application server.

Introduction A way to add methods or fields to an existing class, to bring multiple inheritance to plain Java classes or to attach a new API to an existing object model. Used in JBoss 4.0.

Joinpoints Points, or hooks, in a program’s execution where enhancements can be added or behaviors attached. For example, joinpoints could define calls to specific methods in a class.

Pointcuts Program constructs that designate joinpoints and collect specific context at those points. In AOP, pointcuts define the points in your model where advice will be applied.

Weave To assemble an individual concern into a process by interlacing different execution-logic fragments according to some supplied criteria.

Metadata Additional information that can be attached to a class or a given instance of an object, either statically or at runtime. Metadata helps when writing truly generic aspects that can be applied to any object, but the logic needs to know class-specific information.

面向方面程序设计

面向方面程序设计(AOP)是一种编程方法,允许以程序的整体特性来确定它如何编译成可执行程序。要说明AOP的概念,可以将方面编程类比成织布,这时纱线自动织成布。而没有AOP,程序员必须用手来织布。

AOP是对面向对象程序设计的补充,它允许开发人员动态修改静态的面向对象模型,以生成能成长的系统,来满足新的要求,从而让应用程序在发展过程中适应新的特性。

AOP为把横切代码抽象提供了解决方案,而横切代码在没有与这些代码功能关联性的情况下跨跃了对象的层次。AOP让你将横切代码抽象进入另外的模块(称作方面),来替代将横切代码嵌入类,然后动态地在需要它的地方应用这些代码。通过定义对象模型中应该应用横切代码的具体地方(称作点切),就能获得横切代码的动态应用。在运行时或编译时,依据你的AOP架构,横切代码注入到特定的点切。从本质上讲,AOP允许你将新的功能引入对象,而对象不需要拥有任何有关引入的知识。

面向方面软件开发(AOSD)是软件开发的新方法,它要解决其他方法(如面向对象程序设计)中固有的局限性。AOSD通过提供系统的识别、分离、表示和组合等方法,目的是要解决横切关注。横切关注被封装在其他的模块中,称作方面,从而可以促进本地化。这就带来了对模块化的更好支持,因此降低了开发、维护和升级的成本。

下面是在面向方面程序设计时常用的一些术语:

方面(Aspect)

方面是与一个程序的具体特性有关联的子程序。当特性改变时,就会影响到整个程序。方面子程序用作一类称作方面编织器的新编译器的一部分。

方面是一个与类相似的结构,用于解决横切类的关注。方面可以包含方法和属性、扩展其他的类或方面以及实现接口。

AOP的方面将告知和点切引入功能单元,与面向对象程序设计使用类来包装属性和方法很相似。

AspectC++

对C++编程语言的面向方面的扩展。

AspectJ

对Java编程语言的面向方面的扩展。

忠告(Advice)

在满足某些条件后运行的程序代码。忠告允许你透明地将诸如登录和规格等应用于对象模型。

关注(Concern)

以一种代码结构实现的或者尚未实现的系统中所必需的某些功能或要求。关注的范围上至高级的概念(如安全和服务质量)、下至低级的概念(如高速缓存和普通缓存)。它们可以是功能性的,像特性或商业规则,或者是系统性的,如同步和交易管理。

横切(Crosscutting)

如果与两个关注有关的方法相交叉了,那么这两个关注就横切了。通过应用相同的代码,方面横切了传统的类和方法边界。

截取器(Interceptor)

用于实现JBoss 4.0中的忠告,JBoss 4.0是一种流行的Java应用服务器。

引入(Introduction)

将方法或属性加到已有类上的方式,或者将多个继承带到普通的Java类上,或者将新的API(应用编程接口)连到已有的对象模型。用于JBoss 4.0。

连接点(Joinpoints)

程序执行中可以加入增强行为或附加上行为的点,即钩子。例如,连接点能定义对类中特定方法的调用。

点切(Pointcuts)

指定连接点和收集这些点上具体的上下文的程序构建。在AOP中,点切定义你的模型中的这些点,在这些点上应用忠告。

编织(Weave)

按照提供的一些标准将不同的执行逻辑段组装编译在一起,从而将一个关注装入一个进程。

元数据(Metadata)

附加的信息,能在静态或者运行时加到类上或者对象的给定事例中。元数据在编写真正的通用方面时有帮助,这种方面能应用于任何对象,但程序逻辑需要知道类特定的信息。

责任编辑:rubberface|希赛教研中心

希赛教研中心拥有一支规模200余人的专职教研团队,深耕项目管理、软考、通信工程师、金融财会、厂商认证、考博英语等方向,形成“讲师+助教+班主任+智能学习平台”协同联动的完整教学服务体系:讲师讲透方法、助教盯住进度和答疑、班主任守住节奏、智能平台记录每一步成长——环环相扣,让学员的备考全程有人陪、有反馈、有结果。 师资力量雄厚。主要讲师毕业于 985/211 等知名高校,并拥有海外留学归国人才;职称梯队完善,高、中级职称讲师结构合理,讲师持有软考高级资格证书、PMI系列认证、CSPM高级项目管理培训师证、PeopleCert认证、DAMA认证、英语专八(TEM-8)、PETS-5、华为HCIE、经济师、一级建造师等行业权威资质,兼具深厚理论功底与丰富实战经验。 教研成果卓越。教研团队成员深度参与多项国家标准的研制工作,是 GB/T 47282-2026《项目重大节点评审规范》、GB/T 47285-2026《项目商业分析指南》、GB/T 30339-2026《项目和项目群后评价指南》、GB/T 46210-2025《项目成本管理指南》等国家标准的主要起草人,并担任《中国项目管理知识体系指南》总体编写专家组成员。团队累计主编出版专业图书与教材一百多种,覆盖软考、通信工程师、PMP、CSPM、NPDP等多个认证方向。 教学成效显著。 依托希赛自主研发的开放式智能互动学习平台,团队累计服务学员超百万人,帮助众多学员顺利通过软考、 PMP、CSPM、NPDP、华为认证、通信工程师、管理类联考、考博英语等考试,大批学员考入 985、211 等知名高校深造,以专业与口碑赢得学员和行业的广泛认可。

📅 本文最后更新于 2026-04-03

温馨提示:因考试政策、内容不断变化与调整,本网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准!
新人礼包 新人礼包 课程咨询 课程咨询 企业团报 企业团报 电话咨询 电话咨询

客服热线:400-111-9811

售后投诉:156-1612-8671

公众号 公众号
希赛网公众号二维码
扫二维码 关注希赛网
APP下载 APP下载
希赛网APP下载二维码
扫二维码 下载APP
二维码
二维码
第1步:扫码添加老师微信  第2步:领取备考资料
!
咨询在线老师!