Where do responsibilities belong #24

merged 5 commits into from Mar 9, 2014

2 participants


As I was extracting Frontmatter out of migrator I noticed the post parameter was being passed a lot. It seemed to me that these methods belonged in Post. This is my attempt.

What do you think? improvement? make sense? comments?

natedavisolds added some commits Feb 20, 2014
@natedavisolds natedavisolds Moved valid_post_data to post#valid?
used this method to only write valid posts. Hoping to put this in
PostCollection soon.
@natedavisolds natedavisolds Changed PostCollection to act as an Enumerable
PostCollection held logic to create Post obects from the wp_export file.
However, in Migrator all it did was pull the array of posts.  This array
later was filtered to non-attachment and valid posts.  I moved the logic
of filtering to the PostCollection and implemented it as a immutable
Enumerable.  Now PostCollection behaves like a primitive array.
@natedavisolds natedavisolds Moved the content methods in migrator to Post b051e81
@natedavisolds natedavisolds Moved the options for markdown and include fields
The options of markdown and include fields will be passed to
Post#initialize and be used inside Post.  This helps to not having to
pass them around so much.

@natedavisolds Thanks! I have some mixed feelings about this, namely that a Post now has the blended responsibilities of 1) providing a post interface and 2) writing a post to a markdown file. Previously, I liked that Post was simply an interface to data, and Migrator assumed the responsibilities of doing things with the data.

But I'm open to change. Maybe you see things differently? What are your thoughts?

@mdb I definitely agree about the Post class. I was think that that we are representing two types of Posts... the WPPost and the MiddlemanPost. Would that help the responsibilities?

How about using a PostMigrator to isolate the logic for a single post's transition?


@natedavisolds I see. I suppose I conceive of Post as a Ruby interface to the Wordpress post. Given that, I think I most prefer your PostMigrator option, though I'm flexible.

...curious to hear your thoughts.


@natedavisolds Nice! I like this.


@mdb I moved the migration logic into a MiddlemanPost class. Still not completely sold on this design, but I see some improvements with isolating responsibilities.

@mdb mdb merged commit d4b4fb0 into mdb:master Mar 9, 2014

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment