Hi, MuseScore developers!

I’ve not been a contributor yet… But these days, I’m trying to write some codes 
to implement Jianpu display. My work is based on the previous PR written by 
Brian Yan and committed by 
Eric(https://github.com/musescore/MuseScore/pull/3614).

Now after some improvement(https://musescore.org/en/node/275445) , I’m trying 
to reorganize Jianpu-related classes.
I’m not experienced at designing class hierarchy and not sure what to do about 
JianpuChord’s inheritance. I’ve thought about three possible approaches:


  1.  Currently, `JianpuChord` class is inherited from `Chord`. In this way, 
all constructor methods of ‘JianpuChord’ have to call  constructors of `Chord`. 
But some constructors of `JianpuChord` behave slightly differently from the 
ones of `Chord`.

For example, when constructing a JianpuChord from a Chord object `c`,

  *   We don’t need to copy the stem from the Chord object, as Jianpu has no 
stems.
  *   For each `Note` object in `c._notes`, we need to create a `JianpuNote` 
for it.

So now, both `JianpuChord`’s and `Chord`’s creation processes are considered in 
`Chord`’s constructor.

This causes lots of codes to be modified in chord.cpp because of additional 
logic for `Jianpu`(by adding a factory to constructor’s parameters).


  1.  Another way is to make `JianpuChord` inherited from `ChordRest`, as 
`Chord` does. This design will not affect Chord’s implementation.

But in this case, some methods like `setChord(Chord* a)` of `Note` objects 
cannot be used for JianpuChord, because `JianpuChord` is no longer `Chord` type.


  1.  So finally, the third way is to write a base class for both `JianpuChord` 
and `Chord`.

Current `Chord` will be renamed like `StandardChord`, and both `StandardChord` 
and `JianpuChord` will be inherited from the new `Chord` class.

In my opinion, the third way seems more reasonable. Could someone give me some 
guidance on this, so I can make sure I’m on the right way?

Thank you!

Regards,
Songchaow.
_______________________________________________
Mscore-developer mailing list
Mscore-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mscore-developer

Reply via email to