为了准确理解和选择面向对象程序设计中的对象功能扩充方法,提出一个对象功能扩充机制的比较模型。该模型包括动态性、依赖性、类型无关性、层次性和语言要求等几个指标,分别描述了对象功能扩充方法的灵活程度、非功能对象的内聚度、功能对象和非功能对象的耦合程度、对象功能扩充的影响范围等。基于这些指标分析了几种典型的对象功能扩充方法,给出了这些方法的比较结果。比较结果表明,面向方面的程序设计是对象功能扩充的一种有效手段,比较结果对于对象功能扩充方法的选择具有指导意义。
To accurately understand and choose the method of function expansion of objects in object-oriented programming,a model for comparing different methods for extending objects’ functionality is proposed.The model consists of some dimensions,such as dynamic,dependence,type independence,level,language requirements and so on,which are used to describe the flexibility of function expansion method,degree of cohesion of non-functional objects,the coupling of functional objects and non-functional objects,scope of influence of the non-functional objects and so on,respectively.Firstly,several typical methods of function expansion of objects are analyzed based on the model.Then,the comparison results are given.The results show that aspect-oriented programming is an effective approach for extending objects’ functionality.The results contribute to the choice of function expansion method effectively.