Good work!
##The good stuff:##
- Very nice that you created separate
to_s
methods for yourpost
class andcomment
class, and that yourpost
classto_s
utilizes the comment class to_s. Very sharp separation of responsibilities! - Very wise and clean to separate the parsing of the data and creating of the objects from the rest of your code. Also I like the names of your modules because they clearly convey what each module is doing:
PostFactory
andCommentFactory
. These modules show you are grasping what it means to separate responsibilities. - Good use of map_with_index here
##Stuff to work on:##
- It looks like your add_comment method is doing a lot more than adding one
comment
object to yourpost
object; it is actually creating multiplecomment
objects via yourCommentFactory
module, and then adding all of thosecomment
objects to yourpost
object. This is a mixing of responsibilities! We want each of our methods to have a single responsibility. Thus youradd_comment
method should do exactly one thing: add onecomment
to yourpost
. Like this:def add_comment(comment) @comments << comment end
The creating of `comment` objects should not occur in your `add_comment` method. (It needs to occur, but not here. That's for another method!)
* Your `to_s` method in your `comment` class has [two lines](https://github.com/nyc-chorus-frogs-2016/scraping-hn-1-building-objects-challenge/blob/pair-jesskrich%2Csan115/comment.rb#L13-L14), but watch out: without an explicit return statement, Ruby will only return the last line in a method. Thus, this `to_s` method is only printing `@content` to the console; it is simply ignoring `@user_name`. (That's why the user names are not printing to the console.) (Side thing for when you have time: check out "Some tips on using to_s" in [this gist for another pair](https://gist.github.com/philsof/b1129c5a04c067714690), to get some tips on how to better utilize a `to_s` method.
* Heads up: [This line](https://github.com/nyc-chorus-frogs-2016/scraping-hn-1-building-objects-challenge/blob/pair-jesskrich%2Csan115/runner.rb#L11) in your runner code is not doing anything. You could safely delete it.
* Heads up: [this method](https://github.com/nyc-chorus-frogs-2016/scraping-hn-1-building-objects-challenge/blob/pair-jesskrich%2Csan115/comment.rb#L28) is not accurately named. It is actually creating and returning multiple comments, and thus should be named `new_comments` or `create_comments` or something that clearly indicates it is returning more than one comment.
##Challenge:##
When you have time, see if you can refactor your code in such a way that your entire runner code could be simply:
```ruby
hacker_news_url = #put any Hacker News post URL here
my_post = PostFactory.new_post(hacker_news_url)
puts my_post
Hint: You would need to refactor much more than your runner file to achieve this result.
Good work!