Duplicate code in library files - potential refactor needed
FoamyGuy opened this issue · 5 comments
actions failure with details on duplicated sections is here
We want to avoid having duplicated code if possible. One way to avoid it here will be to make a LabelBase
class in __init__.py
with the duplicated parts and extend that in the other types of labels.
I I took a look at this yesterday. For simple modules, I had success creating LabelBase, in the init file, then creating new classes the label and bitmap_label as children of display.Group and LabelBase. The setter and the getter needs to be equal in order to use them, however this could be solved using a belonging flag and change the module behavior. However, for some modules although equal, ie background (color and calculation) the way both libraries do some calculations, is different, and calling methods inside them also, complicating things inside LabelBase . A first glance I did not see any "easy" path for this
I see as the possible easy
to share in the BaseLabel the following modules
- anchored_position
- background_color
- _get_ascent_descent
Bitmap_label is known to save memory, we would need to keep this feature in doing this change as some people have bitmap_label in their projects to save memory.
I will work on this some tonight or tomorrow as well.
Unfortunately I think we may need to get this sorted before we can merge the other PRs because this will cause actions to fail currently.
@FoamyGuy thanks, Agree, we will work on this, let me know if you want that we do a little brainstorm session.
@jposada202020 I'm going to be working on this some tonight starting in a little bit. If you are around and still interested in brainstorm session ping me on Discord.
@FoamyGuy working in the turning text. Enclosed is a prototype that uses the internal machine of label
will wait in your findings..