4 ms·
I would call this class by what it is ("CommentPoster") instead of what it does ("PostComment"). CommentPoster.new(@comment).post In this case, it might be
by Smudge 14y ago
I would call this class by what it is ("CommentPoster") instead of what it does ("PostComment").
CommentPoster.new(@comment).post
In this case, it might be a premature optimization, but I find that classes like this are a lot more testable than controller logic. One thing, though. I would pull lines like this out of CommentPoster and put them back into the controller:
LanguageDetector.new(@comment).set_language
SpamChecker.new(@comment).check_spam
CommentMailer.new(@comment).send_mail
This keeps the important steps a bit more mutable.