ulabel icon indicating copy to clipboard operation
ulabel copied to clipboard

Code Structure Could Use a Refactor

Open neheller opened this issue 4 years ago • 3 comments

Currently the vast majority of the source code lives in a single class (ULabel) within the src/index.js file. In the long run, it would be nice to break this up into various additional files and classes. Off the top of my head, the following might make for good classes

  • Geometric Utilities
    • For things like finding nearest point on a line etc.
  • HTML Builder
    • To prepare the container class when constructor is called
  • Event Listener
    • To detect and dispatch all interactions by the user
  • Subtask
    • A documented set of calls for things like
      • Beginning annotation
      • Continuing annotation
      • Ending annotation
      • Editing annotation
  • Dialog Handler
    • To manage visiblity and position of dialogs
  • Toolbox View Handler
    • A class in charge of handling the toolbox view
  • Canvas View Handler
    • A class in charge of handling the canvas (set of canvasses, really) view
    • Methods like
      • Draw annotation
  • Annotation
    • A class in charge of maintaining information about annotations, like
      • Containing box
      • Color
  • Action Stream
    • A class that maintains the set of actions within each subtask
    • Events would be placed on the action stream before/as they were dispatched?
  • ID Dialog
    • Certainly should encapsulate the handlers and view controller associated with this somehow

Of course, there's quite a bit more fleshing out to do before working on this, but in general I think it will pay off in the long run. Ultimately, what I need is a firm workflow for each interaction that includes

  • Storing the information about that interaction
  • Changing the objects' states accordingly
  • Updating the view

This is all there now in some shape or form, but it's starting to get muddled together, and the size of the file makes it difficult to debug and refactor.

neheller avatar Feb 26 '21 00:02 neheller