re: I'm Sandi Metz, Ask Me Anything! [Finished] VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Hey Sandi, thanks so much for doing this AMA! I'm not too sure if this is related to object-oriented design, but I was wondering about this code s...
 

I'm not Sandi Metz but there are a few things that captured my attention about that piece of code.

You're using a service/business/whatever object and that is good ™ (instead of pushing all that code down in the model)

I would pass the book (and the author, unless you infer it from the book object) as an argument to publish book, this makes your code easier to test and mock.

Something like:

def publish_book(book, author)
   finalize_book(book) && author.increase_book_count! && send_announcement_email
end
code of conduct - report abuse