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

fix-#1201/refactor-design-smells #1202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bishaddebroy
Copy link

Refactor JavacTokens to Address Design Smells

Description

This PR implements three refactorings in JavacTokens.java to address several identified design smells. The changes improve code organization and maintainability while maintaining all existing functionality.

Changes Made

1. Extract Class - TokenPosition

  • Created dedicated class for position management
  • Handles pos/endPos fields and related operations
  • Addresses "Unnecessary Abstraction" and "Multifaceted Abstraction" smells
  • Main affected classes: RawTok, CommentWithTextAndPosition

2. Move Method - Position Validation

  • Relocated validation logic to TokenPosition class
  • Validates position indices where position data lives
  • Addresses "Multifaceted Abstraction" smell
  • Improves cohesion of position-related operations

3. Move Field - Position Fields

  • Consolidated pos/endPos fields into TokenPosition
  • Removed duplicate fields from multiple classes
  • Addresses "Leaky Encapsulation" and "Duplicate Abstraction" smells
  • Ensures consistent position handling

Testing

  • All existing tests pass successfully
  • No changes to public APIs
  • Original functionality preserved
  • Verified backward compatibility

Implementation Notes

  • No behavioral changes made
  • Only internal refactoring for better organization
  • Maintains existing interfaces and contracts
  • Follows project coding standards

Related Issues

Resolves #1201 - Design smells in JavacTokens class

Documentation

  • Maintained existing documentation style

Change Impact

  • Risk Level: Low
  • Affected Components:
  • JavacTokens.java

Checklist

  • Code follows project style guidelines
  • All tests pass
  • No new warnings introduced

Additional Notes

These refactorings improve code quality while carefully preserving all existing behavior. The changes make the codebase more maintainable and reduce the likelihood of position-related errors.


/cc @reviewer1 @reviewer2

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

Successfully merging this pull request may close these issues.

Design Smell Refactoring in JavacTokens
1 participant