10 research outputs found
Safer typing of complex API usage through Java generics
When several incompatible implementations of a single API are in use in a Java program, the danger exists that instances from different implementations may inadvertently be mixed, leading to errors. In this paper we show how to use generics to prevent such mixing. The core idea of the approach is to add a type parameter to the interfaces of the API, and tie the classes that make up an implementation to a unique choice of type parameter. In this way methods of the API can only be invoked with arguments that belong to the same implementation. We show that the presence of a type parameter in the interfaces does not violate the principle of interface-based programming: clients can still completely abstract over the choice of implementation. In addition, we demonstrate how code can be reused between different implementations, how implementations can be defined as extensions of other implementations, and how different implementations may be mixed in a controlled and safe manner. To explore the feasibility of the approach, gauge its usability, and identify any issues that may crop up in practical usage, we have refactored a fairly large existing API-based application suite, and we report on the experience gained in the process
The Expression Problem, Gracefully
The âExpression Problemâ was brought to prominence by Wadler in 1998. It is widely regarded as illustrating that the two mainstream approaches to data abstraction â procedural abstraction and type abstractionâ are complementary, with the strengths of one being the weaknesses of the other. Despite an extensive literature, the origin of the problem remains ill-understood. I show that the core problem is in fact the use of global constants, and demonstrate that an important aspect of the problem goes away when Java is replaced by a language like Grace, which eliminates them
Covariant Conversions (CoCo): A Design Pattern for Type-Safe Modular Software Evolution in Object-Oriented Systems
Software evolution is an essential challenge for all software engineers, typically addressed solely using code versioning systems and language-specific code analysis tools. Most versioning systems view the evolution of a system as a directed acyclic graph of steps, with independent branches that could be merged. What these systems fail to provide is the ability to ensure stable APIs or that each subsequent evolution represents a cohesive extension yielding a valid system. Modular software evolution ensures that APIs remain stable, which is achieved by ensuring that only additional methods, fields, and data types are added, while treating existing modules through blackbox interfaces. Even with these restrictions, it must be possible to add new variations, fields, and methods without extensive duplication of prior module code. In contrast to most literature, our focus is on ensuring modular software evolution using mainstream object-oriented programming languages, instead of resorting to novel language extensions. We present a novel CoCo design pattern that supports type-safe covariantly overridden convert methods to transform earlier data type instances into their newest evolutionary representation to access operations that had been added later. CoCo supports both binary methods and producer methods. We validate and contrast our approach using a well-known compiler construction case study that other researchers have also investigated for modular evolution. Our resulting implementation relies on less boilerplate code, is completely type-safe, and allows clients to use normal object-oriented calling conventions. We also compare CoCo with existing approaches to the Expression Problem. We conclude by discussing how CoCo could change the direction of currently proposed Java language extensions to support closed-world assumptions about data types, as borrowed from functional programming
A Mechanism for Extensible Mutual Recursion
Abstract This paper summarizes an approach to extensible mutual recursion using what the author calls, "open modules." An open module effectively parameterizes its content so that it can be used both for the current module and future, extending modules. This paper discusses some of the issues with extensible mutual recursion, describes an open module construct and gives encodings and typing rules for open modules
Type Safe Extensible Programming
Software products evolve over time. Sometimes they evolve by adding new
features, and sometimes by either fixing bugs or replacing outdated
implementations with new ones. When software engineers fail to anticipate such
evolution during development, they will eventually be forced to re-architect or
re-build from scratch. Therefore, it has been common practice to prepare for
changes so that software products are extensible over their lifetimes. However,
making software extensible is challenging because it is difficult to anticipate
successive changes and to provide adequate abstraction mechanisms over
potential changes. Such extensibility mechanisms, furthermore, should not
compromise any existing functionality during extension. Software engineers
would benefit from a tool that provides a way to add extensions in a reliable
way. It is natural to expect programming languages to serve this role.
Extensible programming is one effort to address these issues.
In this thesis, we present type safe extensible programming using the MLPolyR
language. MLPolyR is an ML-like functional language whose type system provides
type-safe extensibility mechanisms at several levels. After presenting the
language, we will show how these extensibility mechanisms can be put to good
use in the context of product line engineering. Product line engineering is an
emerging software engineering paradigm that aims to manage variations, which
originate from successive changes in software.Comment: PhD Thesis submitted October, 200
Some Challenging Typing Issues in Object-Oriented Languages (Extended Abstract)
Kim B. Bruce 1,2 Department of Computer Science Williams College Williamstown, MA 01267, U.S.A
Vues et transformations de programmes pour la modularité des évolutions
La maintenance consomme une grande partie du coût de développement des logiciels ce qui rend l optimisation de ce coût parmi les enjeux importants dans le monde du génie logiciel. Dans cette thÚse nous visons à optimiser ce coût par rendre ces maintenances modulaires. Pour atteindre cet objectif, nous définissons des transformations des architectures des programmes qui permettent de transformer le programme à maintenir vers une architecture qui facilite la tùche de maintenance voulue. Nous nous concentrons plus sur la transformation entre les architectures à propriétés de modularité duales tels que les patrons de conception Composite et Visiteur. Dans ce contexte, nous définissons une transformation automatique et réversible basée sur le refactoring entre un programme structuré selon le Composite et sa structureVisiteur correspondante. Cette transformation est validée par la génération d une précondition qui garantit statiquement sa réussite. Elle est aussi adaptée afin qu elle prenne en compte la transformation de quatre variations du patron Composite et est validée sur le programme JHotDraw qui comporte ces quatre variations. Nous définissons aussi une transformation réversible au sein du patron Singleton afin de pouvoir bénéficier de l optimisation par l introduction de ce patron et la souplesse par sa suppression selon les exigences de l utilisateur du logiciel.Maintenance consumes a large part of the cost of software development which makes the optimization of that cost among the important issues in the world of software engineering. In this thesis we aim to optimize this cost by making these maintenances modular. To achieve this goal, we define transformations of program architectures that allow to transform a program to maintain into an architecture that facilitates the maintenance tasks required. We focus on transformation between architectures having dual modularity properties such as Composite and Visitor designpatterns. In this context, we define an automatic and reversible transformation based on refactoring between a program structured according to the Composite structure and its corresponding Visitor structure. This transformation is validated by generating a precondition which guarantees statically its success. It is also adapted to take into account the transformation of four variations of Composite pattern and it is then applied to JHotDraw program in which these four variations occur. We define also a reversible transformation in the Singleton pattern to benefit from optimization by introducing this pattern and flexibility by its suppression according to the requirements of the software user.NANTES-ENS Mines (441092314) / SudocSudocFranceF
Pure subtype systems: a type theory for extensible software
This thesis presents a novel approach to type theory called âpure subtype systemsâ,
and a core calculus called DEEP which is based on that approach. DEEP is capable
of modeling a number of interesting language techniques that have been proposed in
the literature, including mixin modules, virtual classes, feature-oriented programming,
and partial evaluation.
The design of DEEP was motivated by two well-known problems: âthe expression
problemâ, and âthe tag elimination problem.â The expression problem is concerned
with the design of an interpreter that is extensible, and requires an advanced module
system. The tag elimination problem is concerned with the design of an interpreter that
is efficient, and requires an advanced partial evaluator. We present a solution in DEEP
that solves both problems simultaneously, which has never been done before.
These two problems serve as an âacid testâ for advanced type theories, because they
make heavy demands on the static type system. Our solution in DEEP makes use of the
following capabilities. (1) Virtual types are type definitions within a module that can
be extended by clients of the module. (2) Type definitions may be mutually recursive.
(3) Higher-order subtyping and bounded quantification are used to represent partial
information about types. (4) Dependent types and singleton types provide increased
type precision.
The combination of recursive types, virtual types, dependent types, higher-order
subtyping, and bounded quantification is highly non-trivial. We introduce âpure subtype
systemsâ as a way of managing this complexity. Pure subtype systems eliminate
the distinction between types and objects; every term can behave as either a type or
an object depending on context. A subtype relation is defined over all terms, and subtyping,
rather than typing, forms the basis of the theory. We show that higher-order
subtyping is strong enough to completely subsume the traditional type relation, and
we provide practical algorithms for type checking and for finding minimal types.
The cost of using pure subtype systems lies in the complexity of the meta-theory.
Unfortunately, we are unable to establish some basic meta-theoretic properties, such as
type safety and transitivity elimination, although we have made some progress towards
these goals. We formulate the subtype relation as an abstract reduction system, and we
show that the type theory is sound if the reduction system is confluent. We can prove
that reductions are locally confluent, but a proof of global confluence remains elusive.
In summary, pure subtype systems represent a new and interesting approach to
type theory. This thesis describes the basic properties of pure subtype systems, and
provides concrete examples of how they can be applied. The Deep calculus demonstrates
that our approach has a number of real-world practical applications in areas that
have proved to be quite difficult for traditional type theories to handle. However, the
ultimate soundness of the technique remains an open question