Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize method binding patterns across the codebase #1173

Open
williamsyang-work opened this issue Feb 11, 2025 · 0 comments
Open

Modernize method binding patterns across the codebase #1173

williamsyang-work opened this issue Feb 11, 2025 · 0 comments

Comments

@williamsyang-work
Copy link
Contributor

williamsyang-work commented Feb 11, 2025

Description:

Our codebase contains legacy method binding patterns that add unnecessary complexity. These patterns, likely originating from Java development practices, include method delegation and explicit .bind(this) usage. Since we're using TypeScript with arrow functions, these binding patterns are redundant and can be safely removed.
Current patterns we want to modernize:

// Pattern 1: Method delegation
private onEventHandler = (data: Type) => this.doHandleEvent(data);
private doHandleEvent(data: Type) { }

// Pattern 2: Explicit binding
private onEventHandler = function(data: Type) {
    // implementation
}.bind(this);

Proposed modern approach:

// Clean arrow function implementation
private onEventHandler = (data: Type) => {
    // implementation
}

Implementation Strategy:

Individual PRs will target specific modules or related components
Each PR will be tagged with this issue for tracking
Changes will be purely structural with no functional modifications
Existing tests will validate that behavior remains unchanged

Success Criteria:

All method delegation patterns replaced with direct arrow function implementations
All explicit .bind(this) calls removed where arrow functions are used
No regression in functionality
Improved code readability and reduced complexity

This modernization effort will help align our codebase with current TypeScript and React best practices while making it more maintainable for the team.
Labels: technical-debt, enhancement, cleanup

williamsyang-work added a commit to williamsyang-work/theia-trace-extension that referenced this issue Feb 11, 2025
Remove redundant method delegation patterns and explicit .bind(this)
usage in favor of arrow functions. This modernization aligns with
TypeScript best practices and reduces unnecessary code complexity while
maintaining identical functionality.

Changes:

Replace method delegation pattern with direct arrow function implementation
Remove explicit .bind(this) calls where arrow functions are used
Maintain existing behavior and functionality
Improve code readability

Related to eclipse-cdt-cloud#1173

Signed-off-by: Will Yang <william.yang@ericsson.com>
williamsyang-work added a commit to williamsyang-work/theia-trace-extension that referenced this issue Feb 11, 2025
Remove redundant method delegation patterns and explicit .bind(this)
usage in favor of arrow functions. This modernization aligns with
TypeScript best practices and reduces unnecessary code complexity while
maintaining identical functionality.

Changes:

Replace method delegation pattern with direct arrow function implementation
Remove explicit .bind(this) calls where arrow functions are used
Maintain existing behavior and functionality
Improve code readability

Related to eclipse-cdt-cloud#1173

Signed-off-by: Will Yang <william.yang@ericsson.com>
williamsyang-work added a commit to williamsyang-work/theia-trace-extension that referenced this issue Feb 11, 2025
Remove redundant method delegation patterns and explicit .bind(this)
usage in favor of arrow functions. This modernization aligns with
TypeScript best practices and reduces unnecessary code complexity while
maintaining identical functionality.

Changes:

Replace method delegation pattern with direct arrow function implementation
Remove explicit .bind(this) calls where arrow functions are used
Maintain existing behavior and functionality
Improve code readability

Related to eclipse-cdt-cloud#1173

Signed-off-by: Will Yang <william.yang@ericsson.com>
bhufmann pushed a commit that referenced this issue Feb 13, 2025
Remove redundant method delegation patterns and explicit .bind(this)
usage in favor of arrow functions. This modernization aligns with
TypeScript best practices and reduces unnecessary code complexity while
maintaining identical functionality.

Changes:

Replace method delegation pattern with direct arrow function implementation
Remove explicit .bind(this) calls where arrow functions are used
Maintain existing behavior and functionality
Improve code readability

Related to #1173

Signed-off-by: Will Yang <william.yang@ericsson.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant