Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider builder pattern for creating diagrams #29

Open
2 tasks
KCarlile opened this issue May 30, 2024 · 0 comments
Open
2 tasks

Consider builder pattern for creating diagrams #29

KCarlile opened this issue May 30, 2024 · 0 comments
Labels
enhancement New feature or request tech debt

Comments

@KCarlile
Copy link
Owner

KCarlile commented May 30, 2024

Background

See this video at 1:35 for an explanation of the builder pattern. Essentially, it may simplify the way that the library is called for configuring a drawing. For example, this:

let gdj2 = new GuitarDiagramsJS();
gdj2.config.canvasID = 'diagram-2-canvas';
gdj2.config.stringNamesEnabled = true;
gdj2.addCanvas('diagram-2');
gdj2.drawNeck();
gdj2.addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square); // add a square marker on string 1, fret 1, text '1'
gdj2.addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle); // add a triangle marker on string 2, fret 2, text '2'
gdj2.addMarker(3, 3, '3', GuitarDiagramsJS.Shape.Diamond); // add a diamond marker on string 3, fret 3, text '3'
gdj2.addMarker(4, 4, '4'); // add a default (circle) marker on string 4, fret 4, text '4'
gdj2.addMarker(5, 0, '0'); // add a default (circle) marker on string 5, fret 0, text '0'
gdj2.addMarker(6, 0, 'X'); // add a default (circle) marker on string 6, fret 0, text 'X'
gdj2.addMarker(3, 1); // add a default (circle) marker on string 3, fret 1, text empty

...might become simpler like this:

let gdj2 = new GuitarDiagramsJS();
gdj2.config.setCanvasID('diagram-2-canvas')
    .setStringNamesEnabled(true);
gdj2.addCanvas('diagram-2')
    .drawNeck()
    .addMarker(1, 1, '1', GuitarDiagramsJS.Shape.Square)
    .addMarker(2, 2, '2', GuitarDiagramsJS.Shape.Triangle)
    .addMarker(3, 3, '3', GuitarDiagramsJS.Shape.Diamond)
    .addMarker(4, 4, '4')
    .addMarker(5, 0, '0')
    .addMarker(6, 0, 'X')
    .addMarker(3, 1);

Acceptance Criteria

  • Determine if a builder pattern would improve the user experience or developer experience
  • If the previous step determines that the builder pattern is desired, implement the builder pattern ❓

Approach

  • TBD

Notes

TBD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tech debt
Projects
Status: Backlog
Development

No branches or pull requests

1 participant