首页> 外文会议>SIGCSE technical symposium on Computer science education >Implementing object equivalence in Java using the template method design pattern
【24h】

Implementing object equivalence in Java using the template method design pattern

机译:使用模板方法设计模式在Java中实现对象等效

获取原文

摘要

A standard practice in object-oriented programming is to implement an operation, called equals in Java, for testing the equality of two objects. The equals method should be defined for every new Java class, but because of the intricacies of inheritance, casting, and dynamic typing, equals is often quite difficult to write correctly. And unfortunately many textbooks present flawed implementations of this operation. In this paper, we present a semantically correct technique for testing object equivalence, a technique that simultaneously brings together important mathematical foundations (equivalence relations), practical programming issues (inheritance, casting, dynamic typing), and sound software design (design patterns) in a natural and compelling way. While Java is used to demonstrate how the semantic flaws are corrected and the design improved using our techniques, the design is general enough that it will be clear how the same ideas could easily be extended to other languages such as C++.
机译:面向对象编程的标准做法是实现一个操作,该操作在Java中称为equals,用于测试两个对象的相等性。应该为每个新的Java类定义equals方法,但是由于继承,强制转换和动态类型的复杂性,equals通常很难正确编写。不幸的是,许多教科书介绍了该操作的有缺陷的实现。在本文中,我们提出了一种语义正确的技术来测试对象的等效性,该技术同时将重要的数学基础(等效性关系),实际的编程问题(继承性,强制转换,动态类型)和声音软件设计(设计模式)整合在一起。一种自然而引人注目的方式。虽然使用Java演示了如何使用我们的技术纠正语义缺陷和改进设计,但该设计足够通用,可以清楚地看到相同的思想可以轻松地扩展到其他语言(例如C ++)。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号