Refactor command class hierarchy to better support engine independent commands #6443
Labels
refactoring
Status: Pending Review
Indicates that the issue or pull request is awaiting review by project maintainers or collaborators
Type: Feature Request
Identifies requests for new features or enhancements. These involve proposing new improvements.
When implementing an engine independent command (one that performs an abstract operation on all rows), you have to copy code that's already in
EngineDependentCommand::doPost
. Validating the CSRF token, getting the project, creating a process, and handling the response are necessary when writing a command that performs abstract operations on all rows, too.It also seems counter intuitive to implement engine independent commands by extending
Command
directly becauseCommand
has two methods for working with engine configuration:,getEngineConfig()
andgetEngine()
.Proposed solution
From discussion in #1855 and at the suggestion of @tfmorris, I'm wondering what folks think of refactoring the Command class hierarchy to facilitate the development of new commands and refactor existing engine independent commands for maintainability.
In my mind, I think it'd be nice to have three abstract classes:
Command
EngineDependentCommand
EngineIndependentCommand
Alternatives considered
Continue extending
Command
: It's not hugely annoying to extendCommand
and overridedoPost
when writing an engine independent command because those useful methods are hoisted in the super class. But it still feels redundant.Extend
EngineDependentOperation
and ignoreengineConfig
when overridingEngineDependentCommand::createOperation
: This is actually whatReorderColumnsCommand
does.Additional context
As a newbie to OpenRefine's codebase, my initial instinct was just to extend the
EngineDependentCommand
when tinkering around with a command for adding rows to a project.Among the core commands, these engine independent commands (in particular) basically copy
EngineDependentCommand::doPost
or extendEngineDependentCommand
and ignore engine configuration:RenameColumnCommand
RemoveColumnCommand
ReorderColumnsCommand
JoinMultiValueCellsCommand
TransposeColumnsIntoRowsCommand
The text was updated successfully, but these errors were encountered: