[SOLID Principle] Single Responsibility Principle

todo here

data class (val name: String, val email: String)

class AdminDashboardService {

  fun sendNotification(user: User) {
    println(“preparing email content for user ${user.email}”)
    println(“send notification to ${user.email}”)
  }

  fun deleteUser(user: User {
    println(“deleting user with email ${user.email}”)
  }
}

example

data class (val name: String, val email: String)

class UserAccountService {
  
  fun deleteUser(user: User) {
    println(“deleting user with email ${user.email}”)
  }
}

class EmailContentProvider {
  
  fun prepareContent(user: User) {
    println(“preparing email content for user ${user.email}”)
  }
}

class EmailNotificationService {
  
  fun sendNotification(user: User) {
    println(“send notification to ${user.email}”)
  }
}
← Go home