Augmenting Class Mediator for Software Customization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In object-oriented programming, adding a new data member common to all vehicles requires modifying and recompiling the source code of the Vehicle class, which is inconvenient and leads to duplication of source code in subclasses, increasing maintenance costs and error-prone.
Innovation Solution
An augmenting system that allows an augmenting class with a data member to be defined, which can augment an original class, enabling access to the data member as if it were defined in the original class, without requiring access to or recompilation of the original class's source code, using a reference to an instance of the original class to instantiate and access the augmenting class.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If the source code of the Vehicle class is modified to add a new data member, then the new data member can be added to the original class, but the application program must be recompiled and source code access is required
Solution Approach 1:
The patent introduces an augmenting class as an intermediary between the original Vehicle class and the new data member. Instead of modifying the original class directly, the augmenting class acts as a mediator that adds functionality through inheritance and code generation, allowing customization without source code access or recompilation
2Adaptability or versatility
If each subclass inherits from the Vehicle class and adds the color data member separately, then each subclass can have the new data member, but source code duplication occurs
Solution Approach 1:
The augmenting class serves as a universal solution that can be applied to any subclass of the Vehicle class. Instead of duplicating the color data member addition in each subclass, the single augmenting class provides multi-functional capability to all subclasses through inheritance, eliminating code duplication while maintaining adaptability
3Ease of operation
If the Vehicle class source code is provided to users for modification, then users can customize the class, but maintenance becomes problematic when the developer releases modified versions
Solution Approach 1:
The patent segments the class structure into the original Vehicle class and a separate augmenting class. This segmentation allows users to customize the augmenting class independently without modifying the original class source code. When the developer releases modified versions of the Vehicle class, users only need to maintain their augmenting class, which remains compatible through automatic code generation, thus improving ease of maintenance
Data Source
AI summary
An augmenting system for augmenting a program's original class with an augmenting class is provided. In some embodiments, the augmenting system receives a definition of an augmenting class that includes a data member. The augmenting system generates resolution code for the computer program. The resolution code is for accessing a reference to an original instance of the original class and providing a reference to a corresponding augmenting instance of the augmenting class. When processing a statement of the computer program that accesses the data member using the reference to the original instance, the augmenting system generates access code for the computer program. The access code uses the resolution code to retrieve the reference to the augmenting instance for the original instance and accesses the data member based on the retrieved reference to the augmenting instance.


