Approach 1 - sequential approach

Let's consider three services--CustomerInformationService, MailService, and EmailService, which can provide the capabilities listed earlier. We can create NewCustomerService with the following steps:

  1. Call CustomerInformationService to save customer information to the database.
  2. Call MailService to mail the welcome kit.
  3. Call EmailService to send the e-mail notification.

NewCustomerService becomes the central place for all business logic. Imagine if we have to do more things when a new customer is created. All that logic would start accumulating and bloating up NewCustomerService.

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.