给定一个对象(比如下面定义的Foo),静态横切使得创建新方法、添加附加的构造函数,甚至改变继承层次都变得十分简单。
Given an object (such as Foo, defined below), static crosscutting makes it quite simple to create new methods, add additional constructors, and even alter the inheritance hierarchy.
为代码添加枚举功能非常简单,只需在一个打开的记录存储上创建一个RecordEnumeration对象并遍历所有记录即可。
Incorporating enumeration into your code is as easy as creating a RecordEnumeration object from an open record store and looping through each record.
如清单2所示,在一个对象中添加一个新的方法和在一个方面中定义一个方法是同样简单的。
Adding a new method to an object is as simple as defining one in an aspect, as shown in Listing 2.
应用推荐