Towards Creating a Static Design Pattern for Double Dispatching Model Signatures

Volodymyr Boublik
{"title":"Towards Creating a Static Design Pattern for Double Dispatching Model Signatures","authors":"Volodymyr Boublik","doi":"10.18523/2617-3808.2021.4.64-71","DOIUrl":null,"url":null,"abstract":"The paper investigates a possibility of developing a non-virtual hierarchy for a special case of class signature, which may possess different interpretations. The approach is similar to double dispatching in the C ++ programming language. As an alternative to polymorphism, a non-polymorphic hierarchy has been suggested based on generic programming templates. This hierarchy is based on inverse parametrization for templates enabling constructing a general scheme for the design pattern. The pattern defined a class architecture suitable for static implementation of double dispatched multimethod for a special case of signature- defined interfaces.In fact, any abstract base class (interface) with purely virtual operations must acquire a polymorphic implementation. Besides, the polymorphism itself, the dependence of a virtual function on two objects – “this” and another parameter – requires the use of double dispatch, turning a class member function into a double dispatched multimethod.A preliminary consideration deals with issues of double dispatching in the C++ programming language. Inheritance with polymorphic class member functions is used. This requires special efforts of adding to both bases and derived classes a couple of virtual functions to support dispatching. In any case, this approach, besides using virtual functions, has a disadvantage of violating one of the SOLID principles, namely the principle of dependency inversion: base classes should not depend on derivatives, which negatively affects the quality of the software.Polymorphism is usually understood as the dynamic tuning of a program to the data type of the object that the program will encounter during its execution. That is, by its nature, polymorphism is a purely dynamic characteristic. However, in C++ literature and in practice, you can come across the term “static polymorphism”.At the same time, research of possibilities of generalized programming (templates) allows transferring some dynamic problems to the static level. In particular, a variant of static polymorphism application without virtual functions can be considered.A variant of non-virtual double scheduling has been proposed, generalized in the form of a created design pattern “Signature multimethod”. The use of the newly created pattern is illustrated with an example of implementing classes of complex numbers. The absence of violations of SOLID principles is shown, and the possibility of supplementing the hierarchy with new derived classes without the need to interfere with the structure of the base class is demonstrated.The approach suggested in this work has been used in courses in object-oriented programming at the Faculty of Informatics of Kyiv-Mohyla Academy.","PeriodicalId":433538,"journal":{"name":"NaUKMA Research Papers. Computer Science","volume":"59 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-12-10","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"NaUKMA Research Papers. Computer Science","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.18523/2617-3808.2021.4.64-71","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

The paper investigates a possibility of developing a non-virtual hierarchy for a special case of class signature, which may possess different interpretations. The approach is similar to double dispatching in the C ++ programming language. As an alternative to polymorphism, a non-polymorphic hierarchy has been suggested based on generic programming templates. This hierarchy is based on inverse parametrization for templates enabling constructing a general scheme for the design pattern. The pattern defined a class architecture suitable for static implementation of double dispatched multimethod for a special case of signature- defined interfaces.In fact, any abstract base class (interface) with purely virtual operations must acquire a polymorphic implementation. Besides, the polymorphism itself, the dependence of a virtual function on two objects – “this” and another parameter – requires the use of double dispatch, turning a class member function into a double dispatched multimethod.A preliminary consideration deals with issues of double dispatching in the C++ programming language. Inheritance with polymorphic class member functions is used. This requires special efforts of adding to both bases and derived classes a couple of virtual functions to support dispatching. In any case, this approach, besides using virtual functions, has a disadvantage of violating one of the SOLID principles, namely the principle of dependency inversion: base classes should not depend on derivatives, which negatively affects the quality of the software.Polymorphism is usually understood as the dynamic tuning of a program to the data type of the object that the program will encounter during its execution. That is, by its nature, polymorphism is a purely dynamic characteristic. However, in C++ literature and in practice, you can come across the term “static polymorphism”.At the same time, research of possibilities of generalized programming (templates) allows transferring some dynamic problems to the static level. In particular, a variant of static polymorphism application without virtual functions can be considered.A variant of non-virtual double scheduling has been proposed, generalized in the form of a created design pattern “Signature multimethod”. The use of the newly created pattern is illustrated with an example of implementing classes of complex numbers. The absence of violations of SOLID principles is shown, and the possibility of supplementing the hierarchy with new derived classes without the need to interfere with the structure of the base class is demonstrated.The approach suggested in this work has been used in courses in object-oriented programming at the Faculty of Informatics of Kyiv-Mohyla Academy.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
创建双调度模型签名的静态设计模式
本文研究了类签名的一种特殊情况下,具有不同解释的非虚层次结构的可能性。这种方法类似于c++编程语言中的双调度。作为多态的替代方案,基于泛型编程模板的非多态层次结构已被提出。此层次结构基于模板的逆参数化,支持为设计模式构造通用方案。该模式为签名定义接口的特殊情况定义了一种适合静态实现双调度多方法的类体系结构。实际上,任何具有纯虚拟操作的抽象基类(接口)都必须获得多态实现。此外,多态性本身、虚函数对两个对象(“this”和另一个参数)的依赖要求使用双重分派,从而将类成员函数转换为双重分派的多方法。初步考虑处理c++编程语言中的双调度问题。使用多态类成员函数的继承。这需要在基类和派生类中添加一些虚拟函数来支持分派。无论如何,这种方法除了使用虚函数之外,还有一个缺点就是违反了SOLID原则之一,即依赖倒置原则:基类不应该依赖于派生类,这会对软件的质量产生负面影响。多态性通常被理解为对程序在执行过程中遇到的对象的数据类型进行动态调优。也就是说,就其本质而言,多态性是一种纯粹的动态特性。然而,在c++文献和实践中,您可能会遇到术语“静态多态性”。同时,通过对广义规划(模板)可能性的研究,可以将一些动态问题转移到静态层面。特别是,可以考虑一种没有虚函数的静态多态应用程序的变体。提出了一种非虚拟双调度的变体,并以创建的设计模式“签名多方法”的形式进行了推广。通过一个实现复数类的示例来说明新创建的模式的使用。展示了不违反SOLID原则的情况,并展示了用新的派生类补充层次结构而不需要干扰基类结构的可能性。这项工作中提出的方法已在基辅-莫希拉学院信息学学院的面向对象程序设计课程中使用。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Bicycle Protection System Using GPS/GSM Modules аnd Radio Protocol Parking Spot Occupancy Classification Using Deep Learning Information System Assessment of the Creditworthiness of an Individual Transdisciplinary Information and Analytical Platform Supporting Evaluation Processes Two-Stage Transportation Problem with Unknown Consumer Demands
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1