dn-m / MusicXML

Implementation of the musicXML specification in Swift
MIT License
70 stars 19 forks source link

Handle Empty* types better #178

Closed jsbean closed 4 years ago

jsbean commented 4 years ago

There are a few structures which are just bags of attribute groups (e.g., EmptyPrintStyleAlign, EmptyFont, etc.)

These things seem like implementation details that should only be knowable within the encoding / decoding processes, and not really appropriate to be part of the API.

We could either replace these Empty* types with the attribute groups themselves (e.g., PrintStyleAlign), or perhaps create custom types?

DJBen commented 4 years ago

I think the empty-* attribute groups are shorthands of attributes plus the constraint of empty content model. It is transparent in encoding and decoding. IMO we should not use them. Instead, replace the empty-* with attribute groups.

For example, music font can just be

struct MusicFont {
  let font: Font
}
jsbean commented 4 years ago

I agree. I tried this within Defaults.musicFont and .wordFont in #176 and it worked great. Let's continue with this plan in place!