DFRefactor 2024.0
The 2024.0 release is a major rewrite of DFRefactor. The previous concept proved too rigid to extend with new refactoring functions and was replaced with an engine-based architecture.
Architecture
- New refactoring engine. All source-code processing is handled by cRefactorEngine. The engine reads the Functions data table to identify selected functions, then dispatches to the matching implementation in the cRefactorFuncLib repository class (a subclass of cBaseFuncLib). The Functions table is registered through the TestBench program. The table's contents drive the Function List shown in the main UI.
- Three-program split. The single original program was split into DFRefactor.exe (end users), TestBench.exe (advanced users, function development), and DFUnit_TestRunner.exe (advanced users, automated unit tests).
- cBaseFuncLib. The new parent class for cRefactorFuncLib provides shared helpers. The most significant is the tokenizer, which converts a single source line into a struct array of tokens that refactoring functions can analyze robustly.
- Project moved to GitHub. Source, releases, and issue tracking now live at https://github.com/NilsSve/DfRefactor.
Supported DataFlex versions
DFRefactor 2024.0 supports the two most recent DataFlex Studio versions at the time of release: DataFlex 2023 and 2024. The tool can still be used to refactor projects originally created in earlier DataFlex versions, but one of the supported Studio versions must be installed to compile and run DFRefactor itself.
Workflow improvements
- Per-workspace persistence. Function selections and folder selections are saved per workspace and restored on the next session.
- Automatic folder discovery. When a new workspace is opened, all source sub-folders under the workspace home are automatically added to the Select Folders grid. The grid's right-click context menu adds, removes, and toggles folders. Combined with the File Filter drop-down, this defines the file set for each run.
- Opening screen. A Visual-Studio-style opening screen lets users pick a recent workspace or use the Get Started option. The current workspace can also be changed from the main toolbar at any time.
- Bling controls. Uncommenting Define CI_ShowBlingStuff near the top of TestBench.src or DFRefactor.src reveals the toolbar's Theme selector and Snapshot button.
Backup mechanism
- Overwrite-cycle backups. Although it remains the user's responsibility to check in source code before refactoring, DFRefactor uses a backup mechanism with a configurable overwrite cycle (99 days by default; settable in Program Settings). Within the cycle window the original source is preserved across multiple refactoring runs — the existing backup is not overwritten when applying a series of incremental changes. After the window expires, the next run creates fresh backups. This also enables in-cycle undo by moving backups back to their original locations.
TestBench
The TestBench program is intended for advanced developers writing new refactoring functions. It works with a single test file containing legacy code snippets. A small test program is automatically wrapped around the refactored file so it can be compiled to detect obvious errors. Compile errors are shown in a CodeJock tool panel at the bottom of the window, mirroring the Studio's behavior. The Compare Code action launches the configured comparison tool to inspect the refactoring's effect.
Unit testing
Unit testing is central to the new architecture. DFUnit_TestRunner.exe runs a suite of unit tests against cRefactorFuncLib to ensure that edits to the library do not break existing functionality. Tests are defined in oUnit_Tests.pkg; additional fixtures live under AppSrc/Tests/. The DFUnit framework was originally written by Ola Eldöy, enhanced by Bram NijenKamp, and adapted for this project.