Bi-directional Source Code Formatting for Version Control
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Inconsistent source code formatting among developers leads to masked logic problems and inefficiencies in code development, as existing solutions require agreement on coding standards and enforce a common style, limiting individual productivity and introducing inconsistencies.
Innovation Solution
A bi-directional source code format control method that automatically translates source code between customized client-side formatting and a standardized server-side structure, allowing developers to work with individual styles while maintaining lossless version control and eliminating the need for consensus on coding standards.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Stability of the object's composition
If a common coding standard is enforced to ensure consistency, then formatting consistency is improved, but individual developer productivity and flexibility deteriorate
Solution Approach 1:
The patent segments the code representation into two distinct forms: a standardized internal storage format for consistency and version control, and a customized display format for individual developer preference. This segmentation allows the system to maintain formatting consistency in storage while permitting individual productivity through personalized display options, resolving the contradiction between these two requirements.
Solution Approach 2:
The patent introduces an intermediary layer (the server-side formatting translation mechanism) that mediates between the standardized stored code and individual developer preferences. This intermediary automatically translates and transforms code between formats, allowing developers to work with customized formatting while the system maintains consistent standardized storage, thus resolving the contradiction without requiring developers to compromise either consistency or productivity.
2Productivity
If customized formatting is allowed for each developer, then individual productivity is improved, but formatting consistency and code review quality deteriorate
Solution Approach 1:
The system segments the code handling into standardized storage representation and customized display representation. The internal storage maintains consistent standardized formatting for reliable version control and code review, while the display layer adapts to individual developer preferences, thus maintaining both productivity and consistency simultaneously.
Solution Approach 2:
The patent creates a copied and transformed version of the standardized code for display purposes, customized to individual developer preferences. This copying mechanism allows developers to interact with formatted code that suits their productivity needs while the original standardized code remains intact in storage for consistency and review quality.
3Measurement precision
If formatting is removed before comparison, then accurate change detection is improved, but loss of formatting information deteriorates
Solution Approach 1:
The patent segments the code processing into separate formatting and content components. By removing formatting before comparison to improve change detection accuracy, the system then restores and preserves the original formatting information in the stored representation, thus achieving both accurate change detection and preservation of formatting information without loss.
Solution Approach 2:
The patent temporarily discards formatting information during the comparison process to achieve accurate change detection, then recovers and preserves this formatting information in the stored code representation. This discarding and recovering mechanism ensures both measurement precision in change detection and prevents loss of formatting information.
Data Source
AI summary
A method, computer program product, and system includes a processor(s) of a host obtaining, from a client, via a communication connection over a network, a request to commit a modified version of program source code to a repository administered by the host. The processor(s) identify formatting in the modified version implemented by an editor executing on the client and remove the formatting. The processor(s) transform the modified version into a first storage structure that includes content of the modified version without the identified formatting. The processor(s) identify one or more differences between the first storage structure representing the modified version and a second storage structure (an unmodified version of the program source code stored in the repository). The processor(s) store the one or more differences in the repository.


