[Sugar-devel] GSoC Project Update - Music Blocks JavaScript Export

Anindya Kundu anindyaak007 at gmail.com
Mon Jun 29 14:20:44 EDT 2020


I've, so far, made progress on the "MVC" (Model-View-Controller)
refactoring of some important components of Music Blocks, and have built a
proof of concept and a raw design of the code I'm going to export projects
into (and/or provide the functionality to write new Music Blocks projects
with, using text code).


   - *Separated 4 major "note" processing/playing functions* (_playNote,
   _playSwing, _playDotted, _processNote) into a new class called
   NoteController in js/note.js. I'll be revisiting this class and
   restructuring them accordingly in the upcoming weeks, when I'll be working
   on exporting music functionality related blocks.

   - *Refactored logo.js and turtle.js into ES6 compliant standard*. I've
   refactored the existing function prototype based definitions to ES6 class
   definitions, replaced var with let, and added "arrow functions" to get
   rid of reference problems with this keyword. turtle.js previously had
   three object definitions: Turtle, Turtles, and Queue. I've separated
   Turtles to a new file turtles.js and moved Queue into logo.js.

   - *Designed a simple framework to put in practice the "MVC" model*.
   According to the framework, a component's class references two static
   classes: a "model" class and a "view" class. "model" and "view" do not
   interact with each other; they can only make calls to methods in the
   "controller" (which is the main component object itself), and the
   "controlled" can make calls to both. Any external code does not see this
   internal separation - it makes all calls to the main component object
   (controller) and the framework deals with them. There is just one function
   call that needs to be added in the beginning of the constructor of the
   component to bring the three sub components together.

   - *Implemented "MVC" for Turtle and Turtles*. I've refactored the Turtle
   and Turtles classes to comply with the new framework design. In
   addition, I've planned a higher reordering of the components in the
   upcoming weeks - after discussion with my mentor Walter, I've decided that
   the Turtle component should oversee all activities of the "mouse" in
   Music Blocks, i.e. it should oversee all the visual activity and the music
   based activities. Along this idea, I've further refactored the Turtle
   component by transporting all visual activity related members to a new
   class called Painter in a new file turtle-painter.js; every Turtle
   object references a new object of Painter. I've planned to create a
   class called Singer and transport all music activity related members to
   it, as I progress.

   - *Refactored Logo in logo.js*. I've discussed with Walter that Logo
   should only preserve the members required for running projects. I've
   transported "notation" related members (used for "lilypond", "abc", etc.)
   to a new class called Notation in a new file notation.js. There were
   some methods for calculations used by the "Number" blocks, which I moved to
   a new class called MathUtility in js/utils/mathutils.js. In addition,
   I've moved some other methods to blocks.js. There is more work
   remaining, which I'll take up as I begin export work for the music related

   - *Designed a proof of concept of the export code and built a working
   model for the "Graphics" and "Pen" blocks*. This isn't completely stable
   yet. This is what I'm currently working on and I plan to settle on a stable
   model by this week.

My plan for the coming two weeks is to settle on a design framework for the
export code, finalize the API for the "Graphics" and "Pen" blocks, and
implement a working API for the blocks in the "Programming" palette. On
completion of this part, I'll have completed one end - export API and
framework for "Graphics", "Pen", and "Programming" palette blocks. I'll
then begin with refactoring the music related code and start working on the
API related to the "Music" palette blocks.

I've created a GitHub project called Music Blocks JavaScript Export
<https://github.com/meganindya/musicblocks/projects/1> in my fork of Music
Blocks, where I update my progress methodically. In the fork, there is a
branch called js-export where I create and merge duplicates of all pull
requests I create to the original Music Blocks repository, to keep track of
my work.

Thank you. Regards.

*Anindya Kundu*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20200629/a7b182c4/attachment.htm>

More information about the Sugar-devel mailing list