2,456 research outputs found
Subclassing errors, OOP, and practically checkable rules to prevent them
This paper considers an example of Object-Oriented Programming (OOP) leading
to subtle errors that break separation of interface and implementations. A
comprehensive principle that guards against such errors is undecidable. The
paper introduces a set of mechanically verifiable rules that prevent these
insidious problems. Although the rules seem restrictive, they are powerful and
expressive, as we show on several familiar examples. The rules contradict both
the spirit and the letter of the OOP. The present examples as well as available
theoretical and experimental results pose a question if OOP is conducive to
software development at all.Comment: 10 pages, 1 LaTeX file; accompanying C++ and Haskell code and
compilation instruction
Separating Use and Reuse to Improve Both
Context: Trait composition has inspired new research in the area of code
reuse for object oriented (OO) languages. One of the main advantages of this
kind of composition is that it makes possible to separate subtyping from
subclassing; which is good for code-reuse, design and reasoning. However,
handling of state within traits is difficult, verbose or inelegant. Inquiry: We
identify the this-leaking problem as the fundamental limitation that prevents
the separation of subtyping from subclassing in conventional OO languages. We
explain that the concept of trait composition addresses this problem, by
distinguishing code designed for use (as a type) from code designed for reuse
(i.e. inherited). We are aware of at least 3 concrete independently designed
research languages following this methodology: TraitRecordJ, Package Templates
and DeepFJig. Approach: In this paper, we design a new language, where
we improve use and reuse and support the This type and family polymorphism by
distinguishing code designed for use from code designed for reuse. In this way
synthesise the 3 approaches above, and improves them with abstract
state operations: a new elegant way to handle state composition in trait based
languages. Knowledge and Grounding: Using case studies, we show that 's
model of traits with abstract state operations is more usable and compact than
prior work. We formalise our work and prove that type errors cannot arise from
composing well typed code. Importance: This work is the logical core of the
programming language 42. This shows that the ideas presented in this paper can
be applicable to a full general purpose language. This form of composition is
very flexible and could be used in many new languages
Towards a Java Subtyping Operad
The subtyping relation in Java exhibits self-similarity. The self-similarity
in Java subtyping is interesting and intricate due to the existence of wildcard
types and, accordingly, the existence of three subtyping rules for generic
types: covariant subtyping, contravariant subtyping and invariant subtyping.
Supporting bounded type variables also adds to the complexity of the subtyping
relation in Java and in other generic nominally-typed OO languages such as C#
and Scala. In this paper we explore defining an operad to model the
construction of the subtyping relation in Java and in similar generic
nominally-typed OO programming languages. Operads, from category theory, are
frequently used to model self-similar phenomena. The Java subtyping operad, we
hope, will shed more light on understanding the type systems of generic
nominally-typed OO languages.Comment: 13 page
The Subclassing Anomaly in Compiler Evolution
Subclassing in collections of related classes may require re-implementation of otherwise valid
classes just because they utilize outdated parent classes, a phenomenon that is referred to as the subclassing
anomaly. The subclassing anomaly is a serious problem since it can void the benefits of code reuse
altogether. This paper offers an analysis of the subclassing anomaly in an evolving object-oriented compiler.
The paper also outlines a solution for the subclassing anomaly that is based on alternative code reuse
mechanism, named class overriding
An empirical study of evolution of inheritance in Java OSS
Previous studies of Object-Oriented (OO) software have reported avoidance of the inheritance mechanism and cast doubt on the wisdom of ‘deep’ inheritance levels. From an evolutionary perspective, the picture is unclear - we still know relatively little about how, over time, changes tend to be applied by developers. Our conjecture is that an inheritance hierarchy will tend to grow ‘breadth-wise’ rather than ‘depth-wise’. This claim is made on the basis that developers will avoid extending depth in favour of breadth because of the inherent complexity of having to understand the functionality of superclasses. Thus the goal of our study is to investigate this empirically. We conduct an empirical study of seven Java Open-Source Systems (OSSs) over a series of releases to observe the nature and location of changes within the inheritance hierarchies. Results show a strong tendency for classes to be added at levels one and two of the hierarchy (rather than anywhere else). Over 96% of classes added over the course of the versions of all systems were at level 1 or level 2. The results suggest that changes cluster in the shallow levels of a hierarchy; this is relevant for developers since it indicates where remedial activities such as refactoring should be focused
- …
