Page MenuHome

UI Code Quality: Use "params" struct for space type and region callbacks
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Dec 4 2020, 10:39 PM.

Details

Summary

These functions with many arguments can be unwieldy. Aside from the obvious issues
with rewriting the list of arguments and the opportunities for error and frustration
that presents, the long list of arguments make these systems hard to change. So when
an argument should be added, someone might skip that and add some hack instead.

So, as proposed in T73586#1037210, this patch instead uses a "params" struct for
each of these callbacks

  • Use param argument for ARegionType.listener
    • Remove unused window field in region listener
  • Use param argument for SpaceType.listener
  • Use params struct for ARegionType.message_subscribe

Diff Detail

Repository
rB Blender
Branch
cleanup-param-arguments (branched from master)
Build Status
Buildable 11862
Build 11862: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Dec 4 2020, 10:39 PM
Hans Goudey (HooglyBoogly) created this revision.
  • Merge branch 'master' into cleanup-param-arguments

Didn't check in detail, but looks good generally!

I definitely like this, but of course I'm biased :)

This revision is now accepted and ready to land.Jan 17 2021, 9:47 PM

Thanks for looking at it! I was skeptical at first, but as I did more it started to make more sense, and now I really like the change too.