Java中的子类型是一种分形
Subtyping in Java is a Fractal
摘要:
在开发软件时,专业的面向对象(OO)软件开发人员在他们的脑海中保持着软件中类型之间的子类型关系的形象。本文的目的是提出一个观察的图形的子类型关系在Java中,即观察后,泛型--和通配符,特别是-Java,图形的子类型关系不再是一个简单的有向无环图(DAG),在前泛型Java,而是一个分形。此外,这种观察同样适用于其他主流名义类型的OO语言(如C#,C++和Scala),其中泛型和通配符(或其他形式的“方差注释”)是标准功能。因此,这些OO语言中子类型关系的形状比树或简单的DAG更复杂,实际上也是一种分形。考虑到分形的流行,分形观察可以帮助OO软件开发人员保持他们软件的子类型关系的有用和直观的心理图像,即使它比以前更可怕,更令人惊讶。在IDE的适当支持下,分形观察可以帮助OO开发人员在更短的时间内解决他们可能在代码中发现的类型错误,并且更有信心。
英文摘要:
While developing their software, professional object-oriented (OO) software developers keep in their minds an image of the subtyping relation between types in their software. The goal of this paper is to present an observation about the graph of the subtyping relation in Java, namely the observation that, after the addition of generics---and of wildcards, in particular---to Java, the graph of the subtyping relation is no longer a simple directed-acyclic graph (DAG), as in pre-generics Java, but is rather a fractal. Further, this observation equally applies to other mainstream nominally-typed OO languages (such as C#, C++ and Scala) where generics and wildcards (or some other form of 'variance annotations') are standard features. Accordingly, the shape of the subtyping relation in these OO languages is more complex than a tree or a simple DAG, and indeed is also a fractal. Given the popularity of fractals, the fractal observation may help OO software developers keep a useful and intuitive mental image of their software's subtyping relation, even if it is a little more frightening, and more amazing one than before. With proper support from IDEs, the fractal observation can help OO developers in resolving type errors they may find in their code in lesser time, and with more confidence.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。