Skip to content

Conversation

@andeplane
Copy link
Owner

@andeplane andeplane commented Nov 1, 2025

Summary

Fixes #187

Improves the base Modifier class design by making the run() method abstract, ensuring that subclasses must implement it and providing better TypeScript type safety.

Changes

  • Made run() method abstract in the base Modifier class
  • Added clear type enforcement that subclasses must implement run()
  • Improves developer experience with TypeScript errors if not implemented

Benefits

  • Clearer API contract
  • Better developer experience (TypeScript errors if not implemented)
  • Self-documenting code
  • Ensures all modifiers properly implement the run() method

This pull request contains changes generated by a Cursor Cloud Agent

Open in Cursor Open in Web

@cursor
Copy link

cursor bot commented Nov 1, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

- Convert Modifier class to abstract class
- Make run() method abstract to enforce implementation in subclasses
- All 6 modifier subclasses already override run(), so this is safe
- Improves API clarity and TypeScript type safety

Closes #187
@cursor cursor bot force-pushed the cursor/fix-issue-187-and-create-pr-9f41 branch from cacd25c to 7c23377 Compare November 1, 2025 11:27
@andeplane andeplane changed the title Fix issue 187 and create PR refactor: Improve base Modifier class design Nov 1, 2025
@andeplane
Copy link
Owner Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly refactors the Modifier base class to be abstract and introduces an abstract run method. This is a good design improvement that enforces a clear contract for all subclasses. However, this is a breaking change, and the pull request is incomplete because it doesn't update the existing Modifier subclasses. As a result, the project will fail to compile. I've left a critical comment detailing the necessary changes in the subclasses to align with the new abstract base class.

- Convert arrow function properties to method declarations in all subclasses
- Add missing 'everything' parameter to SyncBondsModifier and ColorModifier
- Remove semicolons after method declarations for consistency
- All 6 modifier subclasses now properly implement the abstract run() method

Addresses PR review feedback about breaking changes
- Remove return newParticles from SyncParticlesModifier.run()
- Change return newBonds to return in SyncBondsModifier.run()
- Both methods now correctly return void to match abstract method signature
@andeplane
Copy link
Owner Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great improvement, refactoring the Modifier class to be abstract and ensuring the run() method is implemented by all subclasses. This improves the API contract and type safety. The changes are applied consistently across all modifier implementations. I found one issue in ColorModifier where the everything parameter was not being passed down, which I've commented on. As a potential follow-up, you might consider converting runByType and runByProperty in ColorModifier from arrow function properties to private methods for consistency. Overall, excellent work!

- Pass everything parameter from run() to runByType()
- Update runByType to use everything to bypass caching logic
- When everything=true, forces runByType to execute even if previousColoringMethod matches and colorsDirty is false

Addresses PR review feedback about missing parameter propagation
@andeplane
Copy link
Owner Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great refactoring that improves the design of the base Modifier class by making the run() method abstract. This enforces a clear contract for all modifier subclasses and improves type safety. The changes across the different modifier implementations correctly adapt to this new design. I've added a few suggestions to further improve consistency and code clarity, mainly regarding the use of the new everything parameter in some of the modifiers.

- Pass everything parameter to runByProperty in ColorModifier for consistency
- Update runByProperty signature to accept everything parameter
- Prefix unused everything parameters with underscore in SyncBondsModifier and SyncParticlesModifier to signal intentional non-use

Addresses medium-priority review feedback
@andeplane
Copy link
Owner Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully refactors the base Modifier class by making the run() method abstract, which improves the API contract and type safety for all subclasses. The changes in the subclasses correctly adapt to this new design. I've pointed out a potential issue in ColorModifier where a parameter seems to be unused, and suggested a minor improvement for consistency and encapsulation in the same file. Overall, this is a great improvement to the codebase.

Comment on lines +132 to +136
runByProperty = (
input: ModifierInput,
output: ModifierOutput,
everything: boolean = false,
) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The everything parameter is accepted but not used within the runByProperty method. This might be an oversight. If there are operations that should be forced to run regardless of caching, they should be conditioned on this flag, similar to how it's used in runByType.

Comment on lines +223 to +233
run(
input: ModifierInput,
output: ModifierOutput,
everything: boolean = false,
): void {
if (this.computeName) {
this.runByProperty(input, output);
this.runByProperty(input, output, everything);
} else {
this.runByType(input, output);
this.runByType(input, output, everything);
}
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While run has been correctly converted to a standard method to align with the base abstract class, the helper methods runByProperty and runByType remain as public arrow function properties. For better encapsulation and consistency, consider converting them to private methods.

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.

refactor: Improve base Modifier class design

3 participants