发明名称 Extensible and efficient double dispatch in single-dispatch object-oriented programming languages
摘要 An improved method and system is described for implementing double dispatch extensibly and efficiently in single-dispatch object-oriented programming languages. Objects of type Visitor encapsulate double dispatch functionality, while objects of type Element act as operands. Double dispatch takes place by calling Accept on an object of type Element, passing an object of type Visitor as an argument. Concrete classes of type Element are added in groups, each group deriving from an abstract subclass of Element. An AbstractElement class augments the Element interface with an Accept operation that takes an object of type AppVisitor as an argument, where AppVisitor is an abstract subclass of Visitor. AppVisitor overrides the base class Visit operation to test the type of its Element argument, casting it into an AppElement and calling its augmented Accept. By committing to a client-specific AppVisitor interface as deeply in the Visitor class hierarchy as possible, the set of concrete element subclasses may be extended without changing the Visitor base class. Clients that rely on double dispatch are thus unaffected by such extension. Moreover, by calling the AbstractElement-augmented Accept rather than performing more extensive type tests for concrete Element subclasses, running time is improved over approaches that rely on more extensive type testing. Default functionality is easily accommodated as well.
申请公布号 US6721807(B2) 申请公布日期 2004.04.13
申请号 US20010767253 申请日期 2001.01.22
申请人 INTERNATIONAL BUSINESS MACHINES CORPORATION 发明人 VLISSIDES JOHN MATTHEW
分类号 G06F9/42;G06F9/44;(IPC1-7):G06F9/44 主分类号 G06F9/42
代理机构 代理人
主权项
地址