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

Enable Marshaling support #5

Open
wants to merge 8 commits into
base: release-2.0.0
Choose a base branch
from

Conversation

eduncan911
Copy link
Owner

@eduncan911 eduncan911 commented Apr 7, 2017

Note, this PR is incomplete. Still needs:

  • additional Marshaling work (remaining: Item)
  • basic testing! haven't even tried this stuff yet
  • code coverage
  • examples

I am creating this PR early in transparency for others to see and comment on while work continues.

Backwards Compatibility

While this is targeting a 2.x point release, I am trying to keep it backwards compatible with the existing 1.x releases.

So far it remains backwards compatible as long as you used the API methods in 1.x (podcast.New(...), p.AddItem(...), i.AddEnclosure(...), etc etc). These do not change at all from outside perspective, validated by all unit and integration tests (100% code coverage baby!).

What does break is the removal of specialized fields that were suffixed with "Formatted." For example, Enclosure.TypeFormatted, Enclosure.LengthFormatted, Item.AuthorFormatted, Item.PudDateFormatted and so on. They are all now removed. These were originally added because, frankly, I was too lazy to implement the Marshal interfaces when I originally wrote it - it was a simple hack to just use a 2nd field and manipulate the result during the API calls. These were only used if you bypassed the API methods and attempted to manipulate the Podcast feeds yourself.

So basically, if you stuck to the API methods you were fine. But, if you used the structs only and did everything manually, you could see some code breakage.

Marshaling

I actually came up with a use case lately that I needed to compare previous feeds with newly generated ones (to limit updates). Therefore, I needed a way to read my old generated feed and compare it to the new feed - while ignoring things like PubDate that changes on every invocation. To do this I needed to read an existing feed - and what better way to do this, than when this Podcast package!

Except, it didn't work... I left out some common Marshaling requirements such as XMLName-ing the nil-able fields of structs and had a lot of custom marshaling going on with the Formatted fields.

With the changes to use the Marshaler and Unmarshaler interfaces, I needed to remove those "Formatted" fields. I think this was enough to warrant a full on code review and Major release bump to 2.x.

A bit of Freedom Removed

This unfortunately creates a delima: you no longer have full control over your Feed with the removal of the plaintext "Formatted" string fields from the structs, and the move to use Marshaler and Unmarshaler interfaces. Now, you must use the structs and set items with strongly-typed objects.

To me, this is a no brainer - i want the Marshaler and Unmarshaler interfaces to handle compliant feeds as well as strongly-typed objects.

But to others that wanted complete control over their feeds, with non-compliant specially "Formatted" fields such as their own PubDate format, this 2.x breaks that ability.

I believe this is ok. But, I am open to discussions here.

Too Strict on Enclosure.EnclosureType?

Unmarshaling, where we had none before have you, is implemented in a very strict nature with this version.

See the large comment block in enclosure.go line L122: https://github.com/eduncan911/podcast/compare/develop...feature-Enable-Unmarshaling-Support?expand=1#diff-b2f071ccd78abc2ac116c7a8665bde7eR122

For now, I am keeping it strict. Feel free to discuss.

@eduncan911 eduncan911 self-assigned this Apr 7, 2017
@eduncan911 eduncan911 added this to the 2.x milestone Apr 7, 2017
@eduncan911 eduncan911 force-pushed the feature-Enable-Unmarshaling-Support branch 2 times, most recently from 79dae0e to eaeee5d Compare May 13, 2017 15:34
@coveralls
Copy link

coveralls commented May 13, 2017

Coverage Status

Coverage decreased (-24.9%) to 75.076% when pulling 91f287b on feature-Enable-Unmarshaling-Support into d6317e4 on develop.

@eduncan911 eduncan911 added this to In Progress in Kanban Board May 15, 2017
Repository owner deleted a comment from coveralls Jul 3, 2017
@eduncan911 eduncan911 changed the title Feature: Enable Unmarshaling support Enable Unmarshaling support Feb 5, 2020
@eduncan911 eduncan911 moved this from In Progress to To Do in Kanban Board Feb 6, 2020
eduncan911 added a commit that referenced this pull request Feb 7, 2020
# This is the 1st commit message:

Go Mod and Vendor

# This is the commit message #2:

asd

# This is the commit message #3:

asd

# This is the commit message #4:

asd

# This is the commit message #5:

asd

# This is the commit message #6:

asd

# This is the commit message #7:

asd

# This is the commit message #8:

asd

# This is the commit message #9:

asd
@eduncan911 eduncan911 moved this from To Do to In Progress in Kanban Board Feb 7, 2020
@eduncan911 eduncan911 moved this from In Progress to To Do in Kanban Board Feb 13, 2020
@eduncan911 eduncan911 changed the title Enable Unmarshaling support Enable Marshaling support Feb 24, 2020
@eduncan911 eduncan911 changed the base branch from develop to release-2.0.0 November 4, 2020 21:03
@eduncan911 eduncan911 force-pushed the feature-Enable-Unmarshaling-Support branch from 91f287b to 8bcde0c Compare November 4, 2020 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants