💾 Archived View for soviet.circumlunar.space › zwatotem › snapshot › solution › index.gmi captured on 2024-09-29 at 01:43:59. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
In software engineering the problem of software expandability has been extensively studied for the last years. In the industry the Open-Closed principle, which commands code to be written “open for expansion, closed for modification” is the de-facto standard for writing code that is easy to expand upon and maintainable. Unfortunately, today’s frameworks in the form of programming languages do not allow for easy expansion of both data and behaviours in a way that is easy and follows the Open-Closed principle. This problem has been known and described in literature as Expression Problem. Several studies have presented solutions to the problem within the confines of existing programming languages, but few tried to explore creating new programming tools oriented on solving it directly. The aim of the study is to create a new framework for programming, which enables conceptually easy solution to the Expression Problem, utilizing visual programming.
This thesis will tackle the Expression Problem. In short, Expression Problem occurs during the process of writing a program with some number of types of data, and some number of operations on all these types. When new types and new operations are added consecutively in arbitrary order, one must revisit existing definitions upon these additions. In object-oriented programming one must revisit all existing classes when adding a new method. In functional programming one must revisit all existing function when adding a data case.
In the first chapter we will review the history of the problem research and approaches to its solutions. The we will define Expression Problem in more formally, considering all the interpretations of the informal definition. We will separate a common understanding of the definition agreed upon by all previous papers and follow it by extensions – aspects considered by some works.
In the second chapter we will compare few notable solutions to the Expression Problem present in existing literature. For all of them we will follow a common example, compiled by the author of this work. For each solution a discussion will assess, how it solves the extensions of the Expression Problem defined in the first chapter.
Finally, third chapter will present Visual Solution – a proposal of novel approach to the Expression Problem utilizing techniques of visual (non-textual) programming to solve the organizational aspects of the Expression Problem. The Visual Solution will be discussed in the same categories as previous solutions to provide fair comparison and enlist known limitations.
The main contributions of this work are:
Function: an abstraction for a unit of code separated under a name, parametric with accordance to an arbitrary number of unknowns and reusable via a construct of function call. The Type of function parameter constrains a set of values that this parameter can take based on compile-time check.
Algorithm: a function that at the top level of indirection has a single implementation; generic in regard of its argument type but can in reality differ in implementation on the further levels of indirection via non-generic functions that it uses.
Method: a function, which has an arbitrary number of alternative implementations, of which one is selected at runtime based on the data type of one or more of its arguments.
Object Oriented Programming: a style of programming, where a definition of a data type is inseparable from definitions of functions on this data type and from declarations of partaking in an abstraction. Such a unit of data description, abstraction membership declarations and function definitions we call a Class.
Interface: an abstraction in Object Oriented Programming defined by a set of externally available methods.
Functional Programming: a style of programming, where a data type is defined separately from functions operating on that data type. While in general functional programming is defined by more distinct qualities, they are not a concern of this work.
Compilation unit: a unit of executable code or a runtime linkable library that is a result of a single compilation operation, of code provided directly, and code linked statically by a reference to another available module of source code.
Extension of existing code: a change that regardless of compilation unit it is defined in, could be transferred to an external compilation unit with preservation of all semantics.
Modification of existing code: code change that is made in the compilation unit of the base version and cannot be transferred to an external compilation unit due to specifics of a language it is defined in. Remark: in equivalent code in two different programming languages the same change can be an extension in one and modification in the other.
History of Expression Problem research
Definition of Expression Problem
As this chapter shown, there are different aspects of the Expression Problem, which can be respected or omitted in different situations. Having this in mind, the next chapter will assess solutions proposed in literature separately for each criterion, instead of choosing a specific subset of them. Similarly, following chapter will assess my own solution according to all aspects of Expression Problem in separation.
This thesis has explored the Expression Problem, a fundamental challenge in software engineering that revolves around the tension between extending data types and adding new operations in a modular and type-safe manner. The initial chapters outlined existing solutions, each contributing unique strengths in addressing this challenge. However, these solutions often require trade-offs, particularly in how they organize and structure code, which can lead to inefficiencies and difficulties in maintenance as software evolves.
The Visual Solution proposed in this work introduces a novel approach inspired by spreadsheet pivot tables, aiming to overcome the limitations of traditional code organization methods. By separating program semantics from its representation, this solution allows developers to view and manipulate code through different organizational lenses, depending on the task at hand. This flexibility enables programmers to optimize code organization dynamically, aligning it with current development needs without being locked into a single structure.
Through the use of a visual environment that supports multiple views — class view, method view, concept view — this solution provides a more intuitive and adaptable way to manage the complexities of the Expression Problem. It ensures that code can be organized according to various concerns, minimizing scattering and tangling, which are common in traditional approaches. The Visual Solution also maintains static type safety and reduces code overhead by introducing roles and concepts, which streamline polymorphism and method implementation.
While the theoretical framework for the Visual Solution is well-defined, it remains unimplemented in practice. Implementing this solution is necessary to validate its practical utility, assess its effectiveness in real-world scenarios, and evaluate the runtime complexity of the underlying algorithms. Only through such an implementation can the solution's true potential and any unforeseen limitations be fully understood.
While the solution shows promise in enhancing code organization and addressing the Expression Problem within self-contained programs, there are areas that require further exploration, particularly concerning external extensibility and composability. These aspects are crucial for evaluating the solution's applicability in larger, modular systems where interaction across module boundaries is necessary.
In conclusion, the Visual Solution represents a significant step forward in the ongoing quest to solve the Expression Problem. It provides a more flexible and user-friendly approach to code organization, potentially improving the maintainability and evolution of software. Future work should focus on implementing this solution to verify its practical application and to refine the approach, as well as exploring open extensions.