Creating an interface for BusinessServiceImpl

To make the code even more loosely coupled (as we start writing the tests), let's create an interface for BusinessService and have BusinessServiceImpl updated to implement the interface:

    public interface BusinessService { 
long calculateSum(User user);
}
public class BusinessServiceImpl implements BusinessService {
//.... Rest of code..
}
Using interfaces helps to create loosely coupled code. The exact interface implementation of DataService to use can be changed without changing the code of BusinessServiceImpl.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset