January 2018
Intermediate to advanced
414 pages
10h 29m
English
One thing that we may overlook is that our controller and service have a dependency on the actual implementation. This means that if we have an implementation change tomorrow, for example, moving from a database into a different mechanism, we need to change who uses it, so to avoid that, we will create interfaces for them.
First, we will rename our CustomerService to CustomerServiceImpl, and our AccountService to AccountServiceImpl; then, we will create our interfaces:
interface AccountService { fun getAccountsByCustomer(customerId: Int): List<Account>}class AccountServiceImpl : AccountService { override fun getAccountsByCustomer(customerId: Int): List<Account> = listOf(Account(1, 125F), Account(2, 500F))}interface CustomerService ...Read now
Unlock full access