Skip to content

Instantly share code, notes, and snippets.

@victornoel
Created April 2, 2020 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victornoel/ffcefba162028beb6f95f8e08d746d13 to your computer and use it in GitHub Desktop.
Save victornoel/ffcefba162028beb6f95f8e08d746d13 to your computer and use it in GitHub Desktop.
Book book = new Book(
"How to Ruin Everything: Essays",
"Watsky, George"
)
// it has multiple methods related to reviews,
// the interface is not related to books in particular,
// it's part of our domain
Review reviews = new BookReviews(book)
// a ReviewGrading has one method that take a review and rate it,
// there can be many implementation of this grade computation,
// depending on the need, MedianGrading(), etc...
// its responsibility is to generate rates for reviews
// that are meaningful to humans that have to choose if
// they want to read a book or not
ReviewGrading grading = new SuccessCoefficientGrading()
// it implements something like cactoos' Text,
// or maybe there could be a more domain specific interface if needed
// it's responsibility is to format nicely all the stats about a review using one grading strategy
Text stats = new ReviewStats(review, grading)
new Mailing(
new Text("bla bla introduction"),
stats
).send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment