Skip to content

Code-duplication refactoring notes (draft, for discussion) - #18

Merged
fredvs merged 1 commit into
fredvs:mainfrom
damienmeur:refactoring-notes
Jul 26, 2026
Merged

Code-duplication refactoring notes (draft, for discussion)#18
fredvs merged 1 commit into
fredvs:mainfrom
damienmeur:refactoring-notes

Conversation

@damienmeur

Copy link
Copy Markdown
Contributor

Hi Fred — while trying out a new static-analysis tool (argot, which just got Object Pascal support) on StrumPract, it surfaced a handful of copy-pasted routines in the app's own forms (the vendored use/ trees — MSEgui, uos, OvoTag, BGRABitmap — were excluded). I hand-verified each one and wrote them up in REFACTORING-NOTES.md (this PR's only change).

This is a draft / discussion PR — it changes no code, just documents the duplication with exact locations so a future fix only has to be made once. Several past commits (center-dialog, dock layout, EQ tweaks) had to be repeated across copies, which is the pattern these would remove.

Highlights (full list + line numbers in the file):

  • onmouseev / onmouseevw are byte-identicalsongplayer.pas:3722 vs waveform.pas:418 (same 20-line waveform mouse handler, only the name differs).
  • onsetvalvol duplicated verbatimrecorder.pas:1000 vs songplayer.pas:3250 (~68 lines).
  • The dock-refresh block is pasted into 13 forms (the mainfo.basedock … updatelayoutpan loop in every visiblechangeev) → one refreshdocklayouts(parentwidget) helper.
  • The 10-band EQ table + its record are duplicated in recorder.pas and songplayer.pas.
  • Plus paintslider (×2), an ontextedit/show-hint block (~18×), updatelayoutstrum/updatelayoutpan, InitDrawLive, RoundMath (×3 units), and an fptimer vs msetimer consistency nit.

I didn't include the actual refactors because I couldn't compile-test them here — happy to send compile-tested commits for any of these on request, starting with the four cleanest (the two identical handlers, the dock-refresh helper, the shared EQ table). Just let me know which you'd want, or feel free to take the notes and run with them.

🤖 Generated with Claude Code

@fredvs

fredvs commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Hello Damien.
Sorry about the delay, I am a few out of the game for the moment.
I will check your pull request asap.
Many thanks for this.

Fred

@fredvs
fredvs marked this pull request as ready for review July 26, 2026 18:12
@fredvs
fredvs merged commit 03c62ea into fredvs:main Jul 26, 2026
1 check passed
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.

2 participants