-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Codable Conformance #49
Comments
If I got it right from the other discussions/thread I read, I still think that a stable Codable Conformance of the Types could also come directly from the Library if it is done well in a backwards compatible manner tbh |
Right, I'm not against having the package declare the Codable conformance as long as it won't break in the future. IMO using an implicitly defined string value for the raw type of the enum is not ideal because then even fixing the spelling of a case will be a breaking change. If you explicitly tie each case to something that will not change in the future (such as a specific integer value), then you don't run into this problem. |
For example, let's say you changed the ChordType case "minor" to "min" or changed "min5" to "minor5". These would be breaking changes, because the underlying raw value changes for that case. This wouldn't be true if you tied each enum case to a stable value like an integer or a specific string value vs. relying on its implicit definition. |
This approach may work well for simple enum-based types,
So maybe the more complex types should be handled by the User or the Libraries ensure that |
I think someone needs to ...
Maybe we could start with defining proper raw values for all the enum types and get rid of |
The raw value of our ChordType is a String. If you were to change the name of a ChordType enum case in the future then you would break the decoding of any encoding of that case that you have previously made.
IMO if we are set on introducing Codable conformances, we should use some stable raw value when we do it - such as explicitly assigning each case to a specific integer value.
Originally posted by @Matt54 in #47 (comment)
I completely agree that coddle conformance needs to happen, I'll work on it this weekend
The text was updated successfully, but these errors were encountered: